-
I've been trying to get this all night!!!
Here's what I'm trying to do, but it's kinda complicated to explain to try to stay with me!
On a form, I have 2 labels and a text box. I want to use a text file and in it, it a list of about 100 things with 2 things - A street name and a number. Someone told me I can put the street name in "" and then the number after it with a space. Well I want to make it so it displays the street "in the" in the 1st label, and the user has to type in the number for the street in the text box. If they match, then the 2nd label says yes, else, it tells the user the right number. Now my problem is that I don't know how to load the text file and tell VB to load the name in the "" into the label. Then to see if the number and name matches...
Does anyone know a way of doing this?
I'll take ANY suggestions!
Thanks a lot!
-Emo
-
Split function
You can also use the SPLIT function.
set your street adress in the file then a specific sign (eg like an asterics) and then the number. Like this:
Streetname*16
When you load your line in your prog then use the split function. Like this:
Code:
Dim arrTemp() As String
Open "c:\file" For Input As #1
Line Input #1, strInput
Close#1
arrTemp() = Split(strInput, "*") 'Split your string in two diferent pieces, stored in arrTemp
lblStreetName.Caption = arrTemp(0)
lblStreetNumber.Caption = arrTemp(1)
VBBrowser v2.1.6
This 'll work:cool:
WP
-
Hmmm. Interesting solution. I would have done it different, but i think that'll work too.
-
1 Attachment(s)
<?>
Here's a version...attached..
-
Thanks for the reply you guys!
WP, I did that, but I had to get rid of the this line Text1.Text = arrTemp(1) because I don't want to user to see the number, and I want him to input it! So I got stuck on the way of trying see if the number in the file and the number the user inputed match....
I got this...
If Text1.Text = arrTemp(1) Then
but then what? How do I check if the 2 numbers are the same? Also, I guess I'll need some type of loop so it goes to the next line and does the same thing...
P.S. HeSaidJoe, thanks a lot for the file, it helped a lot, but when I try to run the project, it gives me a Run-time error '6', Overflow. The line that the debugger highlights is iCount = iCount + 1
-Emo
-
<?>
It runs fine for me...
How many lines are you rrunning..it it's a lot try changing the Dimension of iCount from integer to Long
Dim iCount as Long
-
ahhhhh
I got the iCount like you said, but now when i run it, VB gives my some Run-time error '62' "Input past end of File"... and it highlights Input #iNum, sStreet, sNumber what is that supposed to mean? I tried putting it before and after the loop, but VB freezes!
Anything?
-Emo
-
This is starting to piss me off!!!:mad:
I still can't get, but I found this and I'm pretty sure it will work but it gives me a Run-time error '6' "syntax error" And it highlights the exit...
Code:
open "path+file" for input as #1
do until eof(1)
input #1,name$
label.caption = name$
if name$ =textbox.text then v$="yes" exit do
loop
-
ughhhhhhhhhh
I see, you 're a little beginner.
The problem was that there was no : between "yes" and "exit do".
A ":" is used to seperated two commands on one line
This has to work (not tested):
Code:
Dim MayContinue As Boolean
Private Sub cmdStart_Click()
Open "path+file" For Input As #1
Do Until EOF(1)
Input #1,name$, number%
lblName.caption = name$
MayContinue = False
Do While Not MayContinue
DoEvents
Loop
If txtNumber.text = number% Then
lblResult.Caption = "Very Good"
Else
lblResult.Caption = "Wrong"
End If
Loop
End Sub
Private Sub cmdCheck_click()
MayContinue = True
End Sub
VBBrowser v2.1.6
Does it?:eek:
WP
-
<?>
EMO
Send me a copy of your file and I will see if I can't get you going...the problem is in the file.
-
HeSaidJoe, I sent you the file to your Yahoo E-mail.
-Emo