Mgreencornerstone
Board Regular
- Joined
- Nov 23, 2005
- Messages
- 116
I am currently using the code below to open a file and retrieve data, and I would like to pull the data up under a different sub. I have used
Sub getinfo()
FileOpenSub
[A1] = Account
End Sub
to attempt to pull up the "Account" text from the file but it did not work. I have about 10 different subs that would pull the data. I would like to streamline this as much as possible so i dont have to include the below sub in every other sub.
Code__________________________________________________________
Private Sub FileOpenSub()
Dim MyFile, Info, Account, AccountName, AccountLast, Filedir
Filedir = "File.log"
MyFile = Dir(Filedir) 'locates the file
If MyFile = "File.log" Then
Dim r As Integer
r = 0
Dim TextLine
Open Filedir For Input As #1
Do While Not EOF(1)
Input #1, TextLine
If r = 0 Then Info = TextLine
If r = 1 Then Account = TextLine
If r = 2 Then AccountName = TextLine
If r = 3 Then AccountLast= TextLine
r = r + 1
Loop
Close #1
End If
End Sub
Sub getinfo()
FileOpenSub
[A1] = Account
End Sub
to attempt to pull up the "Account" text from the file but it did not work. I have about 10 different subs that would pull the data. I would like to streamline this as much as possible so i dont have to include the below sub in every other sub.
Code__________________________________________________________
Private Sub FileOpenSub()
Dim MyFile, Info, Account, AccountName, AccountLast, Filedir
Filedir = "File.log"
MyFile = Dir(Filedir) 'locates the file
If MyFile = "File.log" Then
Dim r As Integer
r = 0
Dim TextLine
Open Filedir For Input As #1
Do While Not EOF(1)
Input #1, TextLine
If r = 0 Then Info = TextLine
If r = 1 Then Account = TextLine
If r = 2 Then AccountName = TextLine
If r = 3 Then AccountLast= TextLine
r = r + 1
Loop
Close #1
End If
End Sub