Results 1 to 13 of 13

Thread: Winsock VB6.0 & VBA

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2018
    Posts
    6

    Question Winsock VB6.0 & VBA

    Hi!
    There is an old SCADA GENESIS32 in it such function, as data transmission on a network is absent, but there is a possibility to write own code on VBA. I want to transfer data from a computer to a web page (at least to a VB6.0 form). I'm aware of the presence of such a component as Winsock, but I have no idea how to work with it in VBA. I found an example of a chat on VB6.0, but without the concept of how to work with this in VBA ...
    Code:
    Private Sub Form_Load()
    Winsock1.LocalPort = 101 
    Winsock1.Listen 
    Form1.Caption = "Host"
    End Sub
     
    Private Sub Text1_Change() 
    Winsock1.SendData Text1.Text 
    End Sub
     
    Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
    If Winsock1.State <> sckClosed Then Winsock1.Close 
    Winsock1.Accept requestID 
    End Sub
     
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) 
    Dim D As String
    Winsock1.GetData D 
    Text2.Text = D
    End Sub
    Code:
    Private Sub Form_Load()
    Winsock1.RemoteHost = "127.0.0.1" 
    Winsock1.RemotePort = 101 
    Winsock1.Connect 
    End Sub
     
     
    Private Sub Text1_Change() 
    Winsock1.SendData Text1.Text 
    End Sub
     
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) 
    Dim DD As String 
    Winsock1.GetData DD
    Text2.Text = DD
    End Sub

  2. #2

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: Winsock VB6.0 & VBA

    Since the question is primarily about how to implement the VBA end of things, I felt that moving this to Office Development would be likely to produce more focused answers.
    My usual boring signature: Nothing

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Winsock VB6.0 & VBA

    but without the concept of how to work with this in VBA ...
    first you need to add a winsock control to your form
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2018
    Posts
    6

    Re: Winsock VB6.0 & VBA

    Quote Originally Posted by westconn1 View Post
    first you need to add a winsock control to your form
    I tried to add a Winsock element to the VBA form but there was an error "subject has no confidence to perform the specified action"

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Winsock VB6.0 & VBA

    try going to
    file > options > trust center > trust center settings >activex settings
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7

    Thread Starter
    New Member
    Join Date
    Apr 2018
    Posts
    6

    Re: Winsock VB6.0 & VBA

    Quote Originally Posted by westconn1 View Post
    try going to
    file > options > trust center > trust center settings >activex settings
    Name:  22.jpg
Views: 1018
Size:  42.1 KB
    I can not...

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Winsock VB6.0 & VBA

    try in application main window menu rather than vba menu

    what application are you working in anyway?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  9. #9

    Thread Starter
    New Member
    Join Date
    Apr 2018
    Posts
    6

    Re: Winsock VB6.0 & VBA

    I work in SCADA itself. It has VBA built inName:  123.jpg
Views: 1058
Size:  24.9 KB

  10. #10

    Thread Starter
    New Member
    Join Date
    Apr 2018
    Posts
    6

    Re: Winsock VB6.0 & VBA

    Quote Originally Posted by westconn1 View Post
    try in application main window menu rather than vba menu

    what application are you working in anyway?
    Quote Originally Posted by perfekt View Post
    I work in SCADA itself. It has VBA built inName:  123.jpg
Views: 1058
Size:  24.9 KB
    What should I do with this?

  11. #11
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Winsock VB6.0 & VBA

    click OK
    i can not read the dialog in the image, but it just looks like a copyright message

    maybe the winsock control is not licensed to use in vba, unless you have vb6 installed, what do you do to bring up the dialog?

    did you find the trust settings?

    if you can not use the winsock control you may have to go to working with the dlls

    it is possible it would easier to create an activex dll in vb.net, then use that dll in VBA
    vb.net is free to download and use
    Last edited by westconn1; Apr 8th, 2018 at 04:41 PM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  12. #12

    Thread Starter
    New Member
    Join Date
    Apr 2018
    Posts
    6

    Re: Winsock VB6.0 & VBA

    Quote Originally Posted by westconn1 View Post
    click OK
    i can not read the dialog in the image, but it just looks like a copyright message

    maybe the winsock control is not licensed to use in vba, unless you have vb6 installed, what do you do to bring up the dialog?

    did you find the trust settings?

    if you can not use the winsock control you may have to go to working with the dlls

    it is possible it would easier to create an activex dll in vb.net, then use that dll in VBA
    vb.net is free to download and use
    Yes, I have installed vb6. I did not find the trust settings. this message I myself caused, it just shows the version of vba.

  13. #13
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Winsock VB6.0 & VBA

    Yes, I have installed vb6.
    then you should be able add the winsock control to a vb6 form

    as i do not have SCADA, never even heard of it, i can not check at all
    in the scada application (not the vba ide) there should be somewhere to change the trust settings

    if you explain exactly what you want to achieve, there may be some alternative to winsock
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

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