-
January 11th, 2013, 02:20 AM
#1
text file content into vb 6.0 variable
how to get the contents of a text file into a variable in vb 6.0?
any help?
-
January 11th, 2013, 07:24 AM
#2
Re: text file content into vb 6.0 variable
You ned to Open the file for reading and store its contents into the variable :
Something like ;
Code:
Dim FileName1 As String 'holds first file path
Dim FileH1 As Integer 'file handle 1
Dim strInOut As String 'holds input
FileName1 = "E:\Test.txt" 'path to 1st file
Open FileName1 For Binary Access Read As #FileH1 'open file
'read the info line by line
strInOut = Space$(LOF(1))
Get #FileH1, , strInOut
Close #FileH1 'close the handles
-
January 11th, 2013, 12:34 PM
#3
Re: text file content into vb 6.0 variable
You could also open it for input and use the Input # method to read the entire file into a variable.
Always use [code][/code] tags when posting code.
-
January 22nd, 2013, 05:27 AM
#4
Re: text file content into vb 6.0 variable
thank you for your response...well i used this...it works...
Code:
Set ftxt = fs.CreateTextFile("D:\xxx\yy.txt", True)
textperl = "initialized text"
Open "D:\xxx\yy.txt" For Input As #1
While Not EOF(1)
Input #1, MyData
value = MyData
somevariable = somevariable & vbNewLine & value
Wend
Debug.Print textperl
Close #1
Set ftxt = Nothing
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
|