|
-
Oct 26th, 2002, 07:14 PM
#1
Thread Starter
New Member
How do I get this >ReadLine to work in the code below
I am new to vb. I am working on this and need help in getting it to work.
Below is how my code looks like. I am trying to read data from an excel spreadsheet on a floppy disk. I am trying to display it based on my search criteria on a reults form. I am frustrated after trying for a whole week and still cannot get it to work.
It keeps erroring at the .ReadLine, the error says -
[object does'nt support this property or method]
Could somebody look in the code to see what I am doing wrong.
I will appreciate help--thanks
-----------------------------------------------------
MAIN FORM CODE
Option Explicit
Public gblnCancel As Boolean
Private Sub cmdCancel_click()
gblnCancel = True
Unload frmPastDueAmt
End Sub
Private Sub cmdGetFile_Click()
'cmd will allow user to browse for a file using the common dialog control'
With dlgGetFile
.CancelError = True
.ShowOpen
txtFileToPrint.Text = .FileName
End With
End Sub
Private Sub cmdOk_Click()
frmResults.Show vbModal
frmResults.PrintFile txtFileToPrint.Text
End Sub
Private Sub Form_Load()
frmPastDueAmt.Show vbModal
If frmPastDueAmt.gblnCancel = True Then
Unload Me
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim iAnswer As Integer
iAnswer = MsgBox("Are you sure you want to cancel?", vbYesNo)
If iAnswer = vbNo Then
Cancel = True
Else
Unload Me
End If
End Sub
+++++++++++++++++++++++++++++++++++++++++++++
RESULTS FORM CODE
Option Explicit
Public Sub PrintFile(strFileName As String)
Dim fsoFileSystem As FileSystemObject 'the file system
Dim tsFileToPrint As TextStream 'the file we will open
Set fsoFileSystem = New FileSystemObject
Set tsFileToPrint = fsoFileSystem.OpenTextFile(strFileName)
With tsFileToPrint
While Not .AtEndOfStream 'loop until the end of file
Print .ReadLine 'read a line and print it
Wend 'loop until the end of file
End With
Set tsFileToPrint = Nothing 'deallocate the text stream
Set fsoFileSystem = Nothing 'deallocate the reference to the file
End SUb
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
|