Results 1 to 1 of 1

Thread: reading text data from a floopy disk

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Posts
    4

    reading text data from a floopy disk

    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 message says- [object does'nt support this property or method]

    I will appreciate help--thanks
    -----------------------------------------------------

    MAIN FORM CODE

    Option Explicit
    Dim lilD As Long
    Dim strSSN As String
    Dim strCardNumber As String
    Dim curAmount As Currency
    Dim dtmCurrent As Date
    Public gblnCancel As Boolean
    Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)

    End Sub

    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 txtFileToPrint_Change()
    ' txtFileToPrint.Text = ""
    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 'get a reference to the file system
    Set tsFileToPrint = fsoFileSystem.OpenTextFile(strFileName) 'open the file

    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 system
    End Sub

    Private Sub Form_Load()

    End Sub
    Last edited by joe mina; Oct 26th, 2002 at 03:39 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width