Click to See Complete Forum and Search --> : winsock, help[solved]
rodrigorules
Apr 23rd, 2005, 11:26 AM
when i press the button, it dont connect, nothing happen
any idea?
Private Sub button_click()
Dim hosty As Variant
Dim sitey As Variant
hosty = host.Text
sitey = site.Text
Winsock1.RemoteHost = hosty
Winsock1.RemotePort = 80
Winsock1.Connect
End Sub
Private Sub Winsock1_Connect()
Dim strCommand As String
Dim strWebPage As String
strWebPage = sitey
strCommand = "GET " + strWebPage + " HTTP/1.0" + vbCrLf
strCommand = strCommand + "Accept: */*" + vbCrLf
strCommand = strCommand + "Accept: text/html" + vbCrLf
strCommand = strCommand + vbCrLf
Winsock1.SendData strCommand
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim webData As String
Winsock1.GetData webData, vbString
TxtWebPage.Text = TxtWebPage.Text + webData
End Sub
RobDog888
Apr 23rd, 2005, 11:30 AM
What was the error message?
hosty is dimmed as a single yet it is trying to be set to an IP address? Check your hosty's value.
MsgBox hosty
Winsock1.RemoteHost = hosty
rodrigorules
Apr 23rd, 2005, 11:31 AM
yea i changed the above, to a Variant
but now nothing happens when i click on the "button"
RobDog888
Apr 23rd, 2005, 11:33 AM
Whats the value of hosty look like?
192.168.1.1 for example or 192.16811 or such?
It is probably not a good idea to dim it as a variant. Use a String instead.
rodrigorules
Apr 23rd, 2005, 11:34 AM
im entering, google.com as the host
thats the host for google, right?
RobDog888
Apr 23rd, 2005, 11:43 AM
What was your original error message?
I think so.
rodrigorules
Apr 23rd, 2005, 11:55 AM
original error, with the data types, as Single, was "Type mismatch"
RobDog888
Apr 23rd, 2005, 12:02 PM
Yes, then String is the correct solution to that error. Step through your code checking varaible values
each line and see whats happening.
Pino
Apr 23rd, 2005, 12:23 PM
Ok can you post me your application? it makes my life easier and help me finda solution quicker,
Your obviously not connecting because the winsock connect sub
strCommand = "GET " + strWebPage + " HTTP/1.0" + vbCrLf
strCommand = strCommand + "Accept: */*" + vbCrLf
strCommand = strCommand + "Accept: text/html" + vbCrLf
strCommand = strCommand + vbCrLf
Wont work + should be &, anyhows post me your application and i'll fix it up.
Pino
(I have just made a simple client which works very similarly, let me see you app and i'll see what i can do)
rodrigorules
Apr 23rd, 2005, 01:38 PM
here is the program source =/
Pino
Apr 23rd, 2005, 01:55 PM
Ok 2 fatal flaws,
1) allways use option explicit.!
2) you decalred a variable in a routine then tried calling it froma nother, you cant do this. Try this. I get a responce but since i'm not brillaint with the commands sent to and from in http check it out.
Option Explicit
Dim hosty As String
Dim sitey As String
Dim strCommand As String
Dim strWebPage As String
Private Sub but_click()
hosty = host.Text
sitey = site.Text
Winsock1.RemoteHost = hosty
Winsock1.RemotePort = 80
Winsock1.Connect
End Sub
Private Sub Winsock1_Connect()
strWebPage = sitey
strCommand = "GET " & strWebPage + " HTTP/1.0" & vbCrLf
strCommand = strCommand & "Accept: */*" & vbCrLf
strCommand = strCommand & "Accept: text/html" & vbCrLf
strCommand = strCommand & vbCrLf
Winsock1.SendData strCommand
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim webData As String
Winsock1.GetData webData, vbString
TxtWebPage.Text = TxtWebPage.Text + webData
End Sub
Pino
rodrigorules
Apr 23rd, 2005, 02:13 PM
hey, it works, thanks :wave:
now do u know how i would be able to Display a website, in my form? (not the source, but the actual site?)
Pino
Apr 23rd, 2005, 02:19 PM
hey, it works, thanks :wave:
now do u know how i would be able to Display a website, in my form? (not the source, but the actual site?)
well i've bene working on trying to 'parse' (as such the actual html of the site) have a look below.
If you just want to opne the site, from the server then have a search on the forums its beena sked many times
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.