|
-
Aug 25th, 2000, 10:13 PM
#1
Thread Starter
Member
When does Inet Control issue a state change? I'm using the .openURL and I need it to display its status, i.e. Connecting to server, connected, downloading, etc..
I have a Sub for state change, but it never executes, so I'm wondering when it will execute?
-
Aug 25th, 2000, 10:28 PM
#2
You can find out by putting this in the Inet_StateChanged event:
Code:
Private Sub Inet1_StateChanged(ByVal State As Integer)
Debug.Print State
End Sub
1 - Start connect
2 - Connecting...
5+ - Connected
10 - Disconnect
If you want to do something when it hits a certain state:
Code:
Private Sub Inet1_StateChanged(ByVal State As Integer)
If State = 2 Then
Debug.Print "Connecting..."
End If
End Sub
Something like that. Hope that helps.
-
Aug 26th, 2000, 03:28 AM
#3
Fanatic Member
Inet State gets fire when you use Inet1.Execute or Inet1.OpenURL
Try this one:
Code:
'OVERALL: Retrieve server response
Private Sub Inet1_StateChanged(ByVal State As Integer)
' Return ResponseCode and ResponseInfo.
If State = icError Then MsgBox Inet1.ResponseCode & ":" & Inet1.ResponseInfo
Select Case State
'Case icHostResolvingHost
' List1.AddItem "icHostResolvingHost"
Case icHostResolved
List1.AddItem "icHostResolved"
Case icConnecting
List1.AddItem "icConnecting"
Case icConnected
List1.AddItem "icConnected"
Case icRequesting
List1.AddItem "icRequesting"
Case icRequestSent
List1.AddItem "icRequestSent"
Case icReceivingResponse
List1.AddItem "icReceivingResponse"
Case icResponseReceived
List1.AddItem "icResponseReceived"
Case icDisconnecting
List1.AddItem "icDisconnecting"
Case icDisconnected
List1.AddItem "icDisconnected"
Case icResponseCompleted
List1.AddItem "icResponseCompleted"
End Select
End Sub
Chemically Formulated As:
Dr. Nitro
-
Aug 26th, 2000, 08:47 AM
#4
Thread Starter
Member
this doesnt work..whats wrong?
Dim b() As Byte
Dim intRemoteVer As Integer
Dim strRemoteVer As String
Private Sub Form_Load()
Form1.Show
b() = InetUpdate.OpenURL("http://*********/update.exe", 1)
Open App.Path & "\update.exe" For Binary Access Write As #1
Put #1, , b()
Close 1
Label1.Caption = "Update Complete!"
Kill App.Path & "\test.exe"
Name App.Path & "\update.exe" As App.Path & "\test.exe"
MsgBox "Update Complete!"
End Sub
Private Sub InetUpdate_StateChanged(ByVal State As Integer)
MsgBox "test"
If State = icConnecting Then
Label1.Caption = "Connecting to server..."
ElseIf State = icConnected Then
Label1.Caption = "Connected. Downloading update..."
ElseIf State = icError Then
Label1.Caption = "Error connecting to server."
End If
End Sub
...
It never hits the statechanged sub (ie the msgbox never pops up..)
-
Aug 26th, 2000, 02:43 PM
#5
Fanatic Member
-change the Close 1 to Close #1
-include these lines before you dim the b()
It will cancel all previous transaction
'PURPOSE: Reset
Inet1.Cancel ' Stops any current operations
Inet1.AccessType = icUseDefault
-check your "http" address
-check you inet control property - remote port should be 80
-are you running behind a fire wall?
-test by comment out the Kill and Name line
-instead of placing in form_load, try placing in form_click for testing purpose only
Chemically Formulated As:
Dr. Nitro
-
Aug 26th, 2000, 07:15 PM
#6
Thread Starter
Member
a
Thanks for the reply....
I had it under click (instead of form_load) before, and it worked, so I moved it to form_load. I wanted to add the "status" box, so That's why i'm asking about the State Change event. I know the rest of the code works, i.e. It connects, downloads, and updates it. The only thing that doesn't is the status box.
I'll try your code and see if it works...I guess I should've done that first eh...hehe...
-------
ok, this doesnt work:
Private Sub cmdCancel_Click()
InetUpdate.Cancel
InetUpdate.AccessType = icUseDefault
Unload Me
End Sub
Private Sub Form_Load()
InetUpdate.Cancel
InetUpdate.AccessType = icUseDefault
Dim b() As Byte
Form1.Show
b() = InetUpdate.OpenURL("http://********/update.exe", 1)
Open App.Path & "\update.exe" For Binary Access Write As #1
Put #1, , b()
Close #1
Label1.Caption = "Update Complete!"
Kill App.Path & "\act.exe"
Name App.Path & "\update.exe" As App.Path & "\act.exe"
MsgBox "Update Complete!"
End Sub
Private Sub InetUpdate_StateChanged(ByVal State As Integer)
MsgBox "test"
If State = icConnecting Then
Label1.Caption = "Connecting to server..."
ElseIf State = icConnected Then
Label1.Caption = "Connected. Downloading update..."
ElseIf State = icError Then
Label1.Caption = "Error connecting to server."
End If
End Sub
Ok, the stateChanged still doesnt fire, and when I click 'cancel', it waits a while (60 seconds..timeout??) before terminating the program.
grr
[Edited by ElectroTism on 08-26-2000 at 08:38 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|