-
Nov 20th, 1999, 04:02 PM
#1
Thread Starter
New Member
Guys,
I have a 'module' in my prgram that opens a text file;
while not eof(1)
Open "a:\text1.txt" for input as #1
input #1,textline
.
.
I want this module to be called in form2 of my project how do I do this
' I seem to have to put another open
' statement here
for i = 1 to 3
for j = 1 to 3
Input #1, temp ' getting an error here
Myarray(i,j) = temp
next j
next i
Any help would be great
-
Nov 20th, 1999, 10:14 PM
#2
You can create a generic function that will open a text file and return the complete text.
Code:
Public Function GetTextFromFile(pstrFileName As String) As String
Dim strBuffer As String
Dim intFFN As Integer
If Len(Dir(pstrFileName)) = 0 Then
MsgBox "File " & pstrFileName & " not found."
Exit Function
End If
intFFN = FreeFile
Open pstrFileName For Input As intFFN
strBuffer = Space(LOF(intFFN))
strBuffer = Input(LOF(intFFN), #intFFN)
Close #intFFN
GetTextFromFile = strBuffer
End Function
Usage: GetTextFromFile TextFilename
Sample: Text1.Text = GetTextFromFile("A:\Text1.txt")
------------------
Serge
Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819
-
Nov 21st, 1999, 01:59 AM
#3
Thread Starter
New Member
How do I call this type of code at the
Input #1 , temp....part of my programme
-
Nov 21st, 1999, 09:48 PM
#4
No, just copy this function to a module. Then, whenever you want to retrieve the text from the file you will do it like this:
Dim strText As String
strText = GetTextFromFile("A:\MyText.txt")
strText now holds the text from the specified file.
------------------
Serge
Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819
-
Nov 22nd, 1999, 01:32 AM
#5
Thread Starter
New Member
Bingo,
Just what I wanted......thx Serge
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
|