Click to See Complete Forum and Search --> : No run-time error on GET timeout
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
MCSE+Internet
Mark Sreeves
Dec 9th, 1999, 06:10 PM
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
Else
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
Mark.Sreeves@Softlab.co.uk
A BMW Group Company
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.