Odd Behavior re: dim as string and then input 
Author Message
 Odd Behavior re: dim as string and then input

Hi vb folks,
this really comes as a surprise to me - I don't have a clue as to what
is escaping me, although something must be.
Here's my problem:
first I do:        dim s,t as string
then I open a file and read a line from it:       input #1, t
and what I get in the string variable t is only the first word from
the first line of my text file, rather than the whole line!
Now, the ONLY change I make in my program is to change the
dim statement to two lines:
dim s as string
dim t as string
and now t contains the whole line!!  puzzling ?

I have two questions:
1. why should variable t behave differently? shouldn't t contain a
whole line of data?
2. what is the easiest way to read from a line in a text file each
word individually (separated by spaces, not commas) ?

Thanks for any reply     - John.



Tue, 24 Feb 1998 03:00:00 GMT  
 Odd Behavior re: dim as string and then input

Quote:

>Hi vb folks,
>this really comes as a surprise to me - I don't have a clue as to what
>is escaping me, although something must be.
>Here's my problem:
>first I do:        dim s,t as string
>then I open a file and read a line from it:       input #1, t
>and what I get in the string variable t is only the first word from
>the first line of my text file, rather than the whole line!
>Now, the ONLY change I make in my program is to change the
>dim statement to two lines:
>dim s as string
>dim t as string
>and now t contains the whole line!!  puzzling ?
>I have two questions:
>1. why should variable t behave differently? shouldn't t contain a
>whole line of data?
>2. what is the easiest way to read from a line in a text file each
>word individually (separated by spaces, not commas) ?
>Thanks for any reply     - John.

I've found this works ok:

dim s as string, t as string

or
dim s$, t$

Graham



Thu, 26 Feb 1998 03:00:00 GMT  
 Odd Behavior re: dim as string and then input
-> Here's my problem:
-> first I do:        dim s,t as string
-> then I open a file and read a line from it:       input #1, t

If you want a whole line, use line input #.



Sat, 28 Feb 1998 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Newbie Question: Dim A() as String /Dim A as String()

2. dim string to dim form

3. Odd behavior with Dates -A2K

4. Access 2.0 odd transaction behavior

5. Odd Behavior With CommitTrans

6. odd Add Note behavior

7. Externally adding tasks via SQL gives odd behavior

8. Odd recalc behavior with shapeobj.duplicate

9. Odd behavior when inserting TextBox1 into header

10. Odd behavior by socket.select()

11. Very odd behavior with DataTable.Select

12. odd behavior in Qbasic

 

 
Powered by phpBB® Forum Software