423,818 Members | 2,250 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,818 IT Pros & Developers. It's quick & easy.

Using Winsocket control DataArrival data shows all garbled up

P: n/a
I tried using the windows winsocket control on my Access form and place
the recieved data in a text box. I got it to work but the data is
coming accross like % and I cant use that information. Is
there a way to descramble this. I'm thinking it might have to do with
using some sort of emulation that can read the info. We have software
right now that connects to our server with VT101 emulation. If this is
what is making it readable how can I convert the data or use a
emulation in my form?

Aug 4 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Actually I haven't even got that far as to send text out, this is just
scrambled data that i'm recieving when I connect. Normally in our
telnet software that came with our host system, when I connect it asked

me for my user name and password, I'm guessing this is what is coming
back accross to me but is unreadable, let me show you my code that i'm
using straight from Microsofts website. Let me know if you can see
where somehting might be incorrect.

Option Explicit
Const EchoPort = 23
Private Sub cmdConnect_Click()
Dim temp As String
temp = InputBox$("Enter a server name...", _
"Connect to the Echo Service", Winsock1.RemoteHost)
If temp <"" Then
If Winsock1.State <sckClosed Then Winsock1.Close
Winsock1.RemoteHost = temp
Winsock1.RemotePort = EchoPort
Winsock1.LocalPort = 0
Winsock1.Connect
End If
End Sub
Private Sub cmdDisconnect_Click()
If Winsock1.State <sckClosed Then Winsock1.Close
cmdConnect.Enabled = True
cmdConnect.SetFocus
cmdDisconnect.Enabled = False
End Sub
Private Sub cmdEcho_Click()
Text1.SetFocus
Winsock1.SendData Text1.Text
cmdEcho.Enabled = False
End Sub
Private Sub Winsock1_Close()
If Winsock1.State <0 Then Winsock1.Close
End Sub
Private Sub Winsock1_Connect()
Text2.SetFocus
cmdConnect.Enabled = False
cmdEcho.Enabled = True
cmdDisconnect.Enabled = True
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim temp As String
temp = String(bytesTotal, "*")
Winsock1.GetData temp, vbString, bytesTotal
Text2.SetFocus
Text2.Text = temp
cmdEcho.Enabled = True
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, _
Description As String, _
ByVal Scode As Long, _
ByVal Source As String, _
ByVal HelpFile As String, _
ByVal HelpContext As Long, _
CancelDisplay As Boolean)
MsgBox "Error: " & Number & vbTab & Description, vbOKOnly, _
"Winsock Control 1 Error"
CancelDisplay = True
End Sub

Aug 4 '06 #2

P: n/a
Does the Winsock know that the vbstring is unicode?
try one of the unicode convert functions.

(david)

"mike11d11" <mi*******@yahoo.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Actually I haven't even got that far as to send text out, this is just
scrambled data that i'm recieving when I connect. Normally in our
telnet software that came with our host system, when I connect it asked

me for my user name and password, I'm guessing this is what is coming
back accross to me but is unreadable, let me show you my code that i'm
using straight from Microsofts website. Let me know if you can see
where somehting might be incorrect.

Option Explicit
Const EchoPort = 23
Private Sub cmdConnect_Click()
Dim temp As String
temp = InputBox$("Enter a server name...", _
"Connect to the Echo Service", Winsock1.RemoteHost)
If temp <"" Then
If Winsock1.State <sckClosed Then Winsock1.Close
Winsock1.RemoteHost = temp
Winsock1.RemotePort = EchoPort
Winsock1.LocalPort = 0
Winsock1.Connect
End If
End Sub
Private Sub cmdDisconnect_Click()
If Winsock1.State <sckClosed Then Winsock1.Close
cmdConnect.Enabled = True
cmdConnect.SetFocus
cmdDisconnect.Enabled = False
End Sub
Private Sub cmdEcho_Click()
Text1.SetFocus
Winsock1.SendData Text1.Text
cmdEcho.Enabled = False
End Sub
Private Sub Winsock1_Close()
If Winsock1.State <0 Then Winsock1.Close
End Sub
Private Sub Winsock1_Connect()
Text2.SetFocus
cmdConnect.Enabled = False
cmdEcho.Enabled = True
cmdDisconnect.Enabled = True
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim temp As String
temp = String(bytesTotal, "*")
Winsock1.GetData temp, vbString, bytesTotal
Text2.SetFocus
Text2.Text = temp
cmdEcho.Enabled = True
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, _
Description As String, _
ByVal Scode As Long, _
ByVal Source As String, _
ByVal HelpFile As String, _
ByVal HelpContext As Long, _
CancelDisplay As Boolean)
MsgBox "Error: " & Number & vbTab & Description, vbOKOnly, _
"Winsock Control 1 Error"
CancelDisplay = True
End Sub

Aug 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.