Old 02-09-2007   #1 (permalink)
Monster Member
 
f1tzy's Avatar
 
Join Date: Jan 2007
Location: .net 3.5 SP1
Age: 18
Posts: 2,402
Rep Power: 5
Default vb6 - Opening Text Files

Code:
Open App.Path & "\test.txt" For Input As #1
aiight just for a start, i want to open a text file into a textbox, looked at that many tutorials my head hurts just a personal project i have been wanting to do for a while finally getting around to it, anyone give me a hand?

lets say we got

Code:
Private Sub cmdOpen_Click()
'once i click this button, txtBox.text will change to the text in the file Test.text which will be in the same folder
End Sub

Private Sub Form_Load()
txtBox.text = ""
End Sub

Private Sub txtBox_Change()
'yeah well this is where the text goes
End Sub
thanks for anyone who can help
__________________
;]
f1tzy is offline   Reply With Quote
Old 02-09-2007   #2 (permalink)
New Member
 
Join Date: Sep 2007
Posts: 6
Rep Power: 0
Default

You don't need anything in the Change event of the textbox.. the change event fires as soon as the text inside the control is different.. you don't want that.

Basically, theres things called File Numbers. Without explaining it in too much detail, its like opening up a new stream.

Code:
Private Sub cmdOpen_Click()
Dim fileNumber As Long
fileNumber = FreeFile() ' Get the next free file number

Open App.Path & "\test.txt" For Input As #fileNumber
    txtBox.Text = Input(LOF(fileNumber), fileNumber) ' Load the text.
Close #fileNumber
End Sub
chem
chem is the best part 5 is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +10. The time now is 10:04 AM.


Powered by vBulletin® Version 3.7.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0