-
Apr 3rd, 2018, 10:59 AM
#1
Thread Starter
New Member
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
-
Apr 3rd, 2018, 12:54 PM
#2
-
Apr 3rd, 2018, 01:33 PM
#3
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
-
Apr 3rd, 2018, 04:40 PM
#4
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
-
Apr 7th, 2018, 03:44 AM
#5
Thread Starter
New Member
Re: Winsock VB6.0 & VBA
Originally Posted by westconn1
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"
-
Apr 7th, 2018, 05:27 AM
#6
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
-
Apr 7th, 2018, 06:07 AM
#7
Thread Starter
New Member
Re: Winsock VB6.0 & VBA
Originally Posted by westconn1
try going to
file > options > trust center > trust center settings >activex settings
I can not...
-
Apr 7th, 2018, 07:42 AM
#8
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
-
Apr 7th, 2018, 10:12 AM
#9
Thread Starter
New Member
Re: Winsock VB6.0 & VBA
I work in SCADA itself. It has VBA built in
-
Apr 8th, 2018, 07:39 AM
#10
Thread Starter
New Member
Re: Winsock VB6.0 & VBA
Originally Posted by westconn1
try in application main window menu rather than vba menu
what application are you working in anyway?
Originally Posted by perfekt
I work in SCADA itself. It has VBA built in
What should I do with this?
-
Apr 8th, 2018, 04:35 PM
#11
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
-
Apr 8th, 2018, 04:53 PM
#12
Thread Starter
New Member
Re: Winsock VB6.0 & VBA
Originally Posted by westconn1
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.
-
Apr 9th, 2018, 03:54 AM
#13
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|