Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why is this a problem: Input #2, vartext1, vartext2, vartext3, vartext

Status
Not open for further replies.

vbstudent

Programmer
Sep 17, 1999
2
US
I'm a VB6 student at UOP and am working on a project. For some reason, my program isn't working, and these lines keep getting highlighted: Input #2, vartext1, vartext2, vartext3, vartext4, vartext5, vartext6, vartext7, vartext8, vartext9<br>
Write #1, Text1.Text, Text2.Text, Text3.Text, Text4.Text, Text5.Text, Text6.Text, Text7.Text, Text8.Text, Text9.Text<br>
Here is the entire code:<br>
<br>
Private Sub Command1_Click()<br>
Open "A:iodemo.txt" For Output As #1<br>
Write #1, Text1.Text, Text2.Text, Text3.Text, Text4.Text, Text5.Text, Text6.Text, Text7.Text, Text8.Text, Text9.Text<br>
Close #1<br>
End Sub<br>
<br>
Private Sub Command2_Click()<br>
Open "A:iodemo.txt" For Input As #2<br>
Input #2, vartext1, vartext2, vartext3, vartext4, vartext5, vartext6, vartext7, vartext8, vartext9<br>
Text1 = vartext1<br>
Text2 = vartext2<br>
Text3 = vartext3<br>
Text4 = vartext4<br>
Text5 = vartext5<br>
Text6 = vartext6<br>
Text7 = vartext7<br>
Text8 = vartext8<br>
Text9 = vartext9<br>
Close #2<br>
<br>
This is for a data entry program. There are 9 text boxes for information to be entered. Can anyone tell me what I've done wrong?
 
The example in VB5 Help looks very similar to your code - have you checked that there's actually something in the file and that the data is comma delimited?<br>
<br>
Mike<br>
--<br>
Mike_Lacey@Cargill.Com<br>

 
Hi vbstudent!<br>
<br>
I saw that you are passing the text property of your text boxes directly in your write statement. I have occasionally had weird problems with doing things like this. Try surrounding them with parentheses:<br>
<br>
Write #1, (Text1.Text), (Text2.Text), (Text3.Text), (Text4.Text), (Text5.Text), (Text6.Text), (Text7.Text), (Text8.Text), (Text9.Text)<br>
<br>
Chip H.<br>

 
Hi chiph! I've got the same problem. Your solution applies only for the write statement. How about the Input one? It's still causing a run time error.
 
I can't believe a six-year old thread has been resurrected like this...

An overflow run-time error
That can be caused by:
1) Trying to read a Long value into an Integer variable (Integers are too small to hold a large number
2) Getting the parameters out of order, and having a string value being read into a numeric datatype (VB will try and convert it for you, but sometimes it just can't)

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
See how your history comes to haunt you. I blame the Web and search engines ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top