From: GS on
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)

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


From: Larry Serflaten on

"GS" <gesansom(a)netscape.net> wrote
> Why are you including the space in the collection of headings?

I did say 'for a quick example' ....

He was to define what a 'header' was. One of the rules might
be; "no trailing spaces" in which case he would have had to add
the code you supplied.

I saw there would be a trailing space, but as it did not effect the
listing I just decided to let it be. Having him in there adjusting the
code to suit his own needs would mean he pretty well understood
what was going on. That is the important part of coding....

LFS


From: Bob Butler on

"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.

From: GS on
on 6/2/2010, Larry Serflaten supposed :
> "GS" <gesansom(a)netscape.net> wrote
>> Why are you including the space in the collection of headings?
>
> I did say 'for a quick example' ....
>
> He was to define what a 'header' was. One of the rules might
> be; "no trailing spaces" in which case he would have had to add
> the code you supplied.
>
> I saw there would be a trailing space, but as it did not effect the
> listing I just decided to let it be. Having him in there adjusting the
> code to suit his own needs would mean he pretty well understood
> what was going on. That is the important part of coding....
>
> LFS

Thanks Larry!
That's reasonable. It's just that his sample results list only includes
the first 'word' as there's nothing between the last character and the
linefeed.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


From: GS on
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

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc