From: Bob Butler on 2 Jun 2010 12:43 "GS" <gesansom(a)netscape.net> wrote in message news:hu603v$388$1(a)news.eternal-september.org... > Bob Butler explained : >> "GS" <gesansom(a)netscape.net> wrote in message >> news:hu5p6c$9hs$1(a)news.eternal-september.org... >>> Larry Serflaten expressed precisely : >>>> txt = Left$(txt, InStr(txt, " ")) >>> >>> Just curious... >>> Why are you including the space in the collection of headings? >>> >>> Shouldn't this >>> txt = Left$(txt, InStr(txt, " ")) >>> >>> be this? >>> txt = Left$(txt, InStr(txt, " ") - 1) >> >> if there is no space then the first example will return a zero-length >> string and the second will raise an error. Depending on the input and >> the desired results that needs to be considered. > > I'm assuming your comment assumes txt is an empty string, in which case I > agree. In the case of Larry's code example, iteration of the list doesn't > leave txt an empty string. Left$("ABC",Instr(1,"ABC"," ")) returns a zero-length string
From: Helmut Meukel on 2 Jun 2010 13:40 "GS" <gesansom(a)netscape.net> schrieb im Newsbeitrag news:hu603v$388$1(a)news.eternal-september.org... > Bob Butler explained : >> "GS" <gesansom(a)netscape.net> wrote in message >> news:hu5p6c$9hs$1(a)news.eternal-september.org... >>> Larry Serflaten expressed precisely : >>>> txt = Left$(txt, InStr(txt, " ")) >>> >>> Just curious... >>> Why are you including the space in the collection of headings? >>> >>> Shouldn't this >>> txt = Left$(txt, InStr(txt, " ")) >>> >>> be this? >>> txt = Left$(txt, InStr(txt, " ") - 1) >> >> if there is no space then the first example will return a zero-length string >> and the second will raise an error. Depending on the input and the desired >> results that needs to be considered. > > I'm assuming your comment assumes txt is an empty string, in which case I > agree. In the case of Larry's code example, iteration of the list doesn't > leave txt an empty string. > Garry, if there is an entry like Grapefruits with only one word, then you would have the same problem. Helmut. BTW, to the OP: how about an entry like Space Shuttles? The heading should be Space Shuttles not Space, shouldn't it?
From: dpb on 2 Jun 2010 13:56 Helmut Meukel wrote: .... > BTW, to the OP: how about an entry like Space Shuttles? > The heading should be Space Shuttles not Space, shouldn't it? Unfortunately, the heading should be "Obsolete Airframes" ... :( --
From: GS on 2 Jun 2010 14:26 Bob Butler brought next idea : > "GS" <gesansom(a)netscape.net> wrote in message > news:hu603v$388$1(a)news.eternal-september.org... >> Bob Butler explained : >>> "GS" <gesansom(a)netscape.net> wrote in message >>> news:hu5p6c$9hs$1(a)news.eternal-september.org... >>>> Larry Serflaten expressed precisely : >>>>> txt = Left$(txt, InStr(txt, " ")) >>>> >>>> Just curious... >>>> Why are you including the space in the collection of headings? >>>> >>>> Shouldn't this >>>> txt = Left$(txt, InStr(txt, " ")) >>>> >>>> be this? >>>> txt = Left$(txt, InStr(txt, " ") - 1) >>> >>> if there is no space then the first example will return a zero-length >>> string and the second will raise an error. Depending on the input and the >>> desired results that needs to be considered. >> >> I'm assuming your comment assumes txt is an empty string, in which case I >> agree. In the case of Larry's code example, iteration of the list doesn't >> leave txt an empty string. > > Left$("ABC",Instr(1,"ABC"," ")) returns a zero-length string I see that. Thanks for pointing this out. -Just goes to show that I don't run into too many situations where this might be a problem. Not that they don't exist, but more that I usually validate string values before I act on them. Nice to know, though, what could result if I did not validate. For example, I would normally put " " into a var like: iPos = Instr$(sz, " ") and validate like this: If iPos > 0 Then 'do stuff -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc
From: GS on 2 Jun 2010 14:29 After serious thinking Helmut Meukel wrote : > "GS" <gesansom(a)netscape.net> schrieb im Newsbeitrag > news:hu603v$388$1(a)news.eternal-september.org... >> Bob Butler explained : >>> "GS" <gesansom(a)netscape.net> wrote in message >>> news:hu5p6c$9hs$1(a)news.eternal-september.org... >>>> Larry Serflaten expressed precisely : >>>>> txt = Left$(txt, InStr(txt, " ")) >>>> >>>> Just curious... >>>> Why are you including the space in the collection of headings? >>>> >>>> Shouldn't this >>>> txt = Left$(txt, InStr(txt, " ")) >>>> >>>> be this? >>>> txt = Left$(txt, InStr(txt, " ") - 1) >>> >>> if there is no space then the first example will return a zero-length >>> string and the second will raise an error. Depending on the input and the >>> desired results that needs to be considered. >> >> I'm assuming your comment assumes txt is an empty string, in which case I >> agree. In the case of Larry's code example, iteration of the list doesn't >> leave txt an empty string. >> > > > Garry, > if there is an entry like > Grapefruits > with only one word, then you would have the same problem. > > Helmut. > > BTW, to the OP: how about an entry like Space Shuttles? > The heading should be Space Shuttles not Space, shouldn't it? I agree. See my reply to Bob. The info is good to know, and I appreciate sharing it with me. -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: How can I implement jagged arrays in VB6? UDT? Next: How to catch app shutdown from windows |