Results 1 to 2 of 2

Thread: No run-time error on GET timeout

  1. #1


    I am using the GET statement to retrieve bytes from a file on a network server. When the connection is lost or is busy(a slow or congested network connection) the GET statement hangs the program. It does not time out and generate a run-time error. I have tried to use the timer event as a timeout yet GET does not release control of the program to allow the timer event or DoEvents to execute. Any suggestions?

    Dave Receveur

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999


    Seeing as no-one else has relpied yet, you could try this.

    I admit it's a bit of a hack but...

    stick a timer and a command button on a form

    Option Explicit
    Const CHUNK = 64
    Dim strData As String 'accumilation of the data read
    Dim position As Long	
    Dim Remaining As Long
    Dim FNum As Long
    Private Sub Command1_Click()
      Command1.Enabled = False
      FNum = FreeFile
      Open "C:\testData.txt" For Binary As FNum
      Remaining = LOF(FNum)
      Timer1.Enabled = True
      position = 1
    End Sub
    Private Sub Timer1_Timer()
    Dim strTemp As String
    If Remaining >= CHUNK Then
      strTemp = Space(CHUNK)
      Remaining = Remaining - CHUNK
      strTemp = Space(Remaining)
      Timer1.Enabled = False
    End If
    Get #FNum, position, strTemp
    strData = strData & strTemp
    position = position + 1
    If Timer1.Enabled = False Then
      Close FNum
      Command1.Enabled = True
    End If
    End Sub
    Mark Sreeves
    Analyst Programmer
    A BMW Group Company

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