Apr 23rd, 2005, 11:26 AM
#1
Thread Starter
Member
winsock, help[solved]
when i press the button, it dont connect, nothing happen
any idea?
VB Code:
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
Last edited by rodrigorules; Apr 23rd, 2005 at 02:42 PM .
Apr 23rd, 2005, 11:30 AM
#2
Re: winsock, help
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.
VB Code:
MsgBox hosty
Winsock1.RemoteHost = hosty
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Apr 23rd, 2005, 11:31 AM
#3
Thread Starter
Member
Re: winsock, help
yea i changed the above, to a Variant
but now nothing happens when i click on the "button"
Apr 23rd, 2005, 11:33 AM
#4
Re: winsock, help
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.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Apr 23rd, 2005, 11:34 AM
#5
Thread Starter
Member
Re: winsock, help
im entering, google.com as the host
thats the host for google, right?
Apr 23rd, 2005, 11:43 AM
#6
Re: winsock, help
What was your original error message?
I think so.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Apr 23rd, 2005, 11:55 AM
#7
Thread Starter
Member
Re: winsock, help
original error, with the data types, as Single, was "Type mismatch"
Apr 23rd, 2005, 12:02 PM
#8
Re: winsock, help
Yes, then String is the correct solution to that error. Step through your code checking varaible values
each line and see whats happening.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Apr 23rd, 2005, 12:23 PM
#9
Re: winsock, help
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
VB Code:
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)
Apr 23rd, 2005, 01:38 PM
#10
Thread Starter
Member
Re: winsock, help
here is the program source =/
Attached Files
Apr 23rd, 2005, 01:55 PM
#11
Re: winsock, help
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.
VB Code:
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
Apr 23rd, 2005, 02:13 PM
#12
Thread Starter
Member
Re: winsock, help
hey, it works, thanks
now do u know how i would be able to Display a website, in my form? (not the source, but the actual site?)
Apr 23rd, 2005, 02:19 PM
#13
Re: winsock, help
Originally Posted by
rodrigorules
hey, it works, thanks
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
Attached Files
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