|
-
Dec 13th, 2004, 07:08 PM
#1
Thread Starter
Junior Member
Reading lines from a text file
First of all, I am far from experienced so if there are any obvious mistakes, it's because I don't know any better.
I have a text file in this format:
Code:
A B
1 356 234
2 275 597
3 365 674
4 286 375
5 256 752
6 674 465
On the form, I have a text box where a user can enter a number. How can I make it so that when a user enters 2 and clicks a button, it will store 275 as variable x and 597 as variable y?
I've got some code that I've been playing with, but I just can't put it together. I don't think it's even worth putting up because it doesn't really do anything. Here's part of it, the rest is just a mess that I don't understand.
Code:
Private Sub Command_Click()
Dim varCount As Integer
Dim varTemp As String
Open "C:\MyFile.txt" For Input As #1
Do Until EOF(1)
varCount = varCount + 1
Line Input #1, varTemp
Loop
Close #1
End Sub
I know I need to use the Split() function somewhere, and that the actual lines have to be stored in a array. I just can't figure out how to incorporate that. I would actually like something like jumping to a line in the text file or something because I think it would be quicker and easier. The text file will contain around 400 lines, but something about bad programming practice? The text file actually originated from Excel, but I figured it would be easier to just use a text file. If it isn't, then that would be even better. If someone could help me out, thanks.
Last edited by Wander; Dec 13th, 2004 at 09:14 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|