|
-
Oct 19th, 2005, 02:16 PM
#1
Thread Starter
Fanatic Member
load different lines into different textboxes
hello,
does anyone know how to load different lines from a file into different textboxes eg. line1 from a textfile goes into text1.text, line 2 from a file goes into text2.text and so on
thanks
-
Oct 19th, 2005, 02:24 PM
#2
Re: load different lines into different textboxes
Well it depends on how many TextBoxes you have.
VB Code:
Dim FileIn As String
Open "C:\Your.txt" For Input As #1 ' Open file for input.
Line Input #1, FileIn ' Read line of data.
Text1.Text = FileIn
Line Input #1, FileIn ' Read line of data.
Text2.Text = FileIn
Line Input #1, FileIn ' Read line of data.
Text3.Text = FileIn
Close #1 ' Close file.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
-
Oct 19th, 2005, 02:46 PM
#3
Re: load different lines into different textboxes
another way..
VB Code:
Dim tmp() As String
Open "C:\File.txt" For Input As #1
tmp() = Split(Input(LOF(1), 1), vbCrLf)
Close #1
'each line of the file is now in the array tmp()
Text1 = tmp(0)
Text2 = tmp(1)
Text3 = tmp(2)
'etc...
'or even better
'Create an array of textboxes
'Make a new textbox.. call it txtData
'now copy & paste it back on the form.. it will ask if you want an array
'yes.. paste as many more as you need..
For x = 0 To txtData.Count - 1
txtData(x) = tmp(0)
Next
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Oct 19th, 2005, 02:47 PM
#4
Thread Starter
Fanatic Member
Re: load different lines into different textboxes
thanks guys
i'll use statics one as it is shorter
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
|