Results 1 to 13 of 13

Thread: winsock, help[solved]

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    61

    Resolved winsock, help[solved]

    when i press the button, it dont connect, nothing happen
    any idea?
    VB Code:
    1. Private Sub button_click()
    2. Dim hosty As Variant
    3. Dim sitey As Variant
    4. hosty = host.Text
    5. sitey = site.Text
    6. Winsock1.RemoteHost = hosty
    7. Winsock1.RemotePort = 80
    8. Winsock1.Connect
    9. End Sub
    10.  
    11.  
    12. Private Sub Winsock1_Connect()
    13. Dim strCommand As String
    14. Dim strWebPage As String
    15. strWebPage = sitey
    16. strCommand = "GET " + strWebPage + " HTTP/1.0" + vbCrLf
    17. strCommand = strCommand + "Accept: */*" + vbCrLf
    18. strCommand = strCommand + "Accept: text/html" + vbCrLf
    19. strCommand = strCommand + vbCrLf
    20. Winsock1.SendData strCommand
    21. End Sub
    22.  
    23. Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    24. Dim webData As String
    25. Winsock1.GetData webData, vbString
    26. TxtWebPage.Text = TxtWebPage.Text + webData
    27. End Sub
    Last edited by rodrigorules; Apr 23rd, 2005 at 02:42 PM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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:
    1. MsgBox hosty
    2. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    61

    Re: winsock, help

    yea i changed the above, to a Variant
    but now nothing happens when i click on the "button"

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  5. #5

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    61

    Re: winsock, help

    im entering, google.com as the host
    thats the host for google, right?

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  7. #7

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    61

    Re: winsock, help

    original error, with the data types, as Single, was "Type mismatch"

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  9. #9
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    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:
    1. strCommand = "GET " + strWebPage + " HTTP/1.0" + vbCrLf
    2. strCommand = strCommand + "Accept: */*" + vbCrLf
    3. strCommand = strCommand + "Accept: text/html" + vbCrLf
    4. 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)

  10. #10

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    61

    Re: winsock, help

    here is the program source =/
    Attached Files Attached Files

  11. #11
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    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:
    1. Option Explicit
    2.  
    3. Dim hosty As String
    4. Dim sitey As String
    5.  
    6. Dim strCommand As String
    7. Dim strWebPage As String
    8.  
    9. Private Sub but_click()
    10.  
    11. hosty = host.Text
    12. sitey = site.Text
    13. Winsock1.RemoteHost = hosty
    14. Winsock1.RemotePort = 80
    15. Winsock1.Connect
    16. End Sub
    17.  
    18.  
    19. Private Sub Winsock1_Connect()
    20. strWebPage = sitey
    21. strCommand = "GET " & strWebPage + " HTTP/1.0" & vbCrLf
    22. strCommand = strCommand & "Accept: */*" & vbCrLf
    23. strCommand = strCommand & "Accept: text/html" & vbCrLf
    24. strCommand = strCommand & vbCrLf
    25. Winsock1.SendData strCommand
    26. End Sub
    27.  
    28. Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    29. Dim webData As String
    30. Winsock1.GetData webData, vbString
    31. TxtWebPage.Text = TxtWebPage.Text + webData
    32. End Sub

    Pino

  12. #12

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    61

    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?)

  13. #13
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: winsock, help

    Quote 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 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
  •  



Click Here to Expand Forum to Full Width