Solved

UDP_listener, how to display a hex string on the Data_Arrived event.

Posted on 2008-09-30
8
297 Views
Last Modified: 2013-12-26
I'm using a simple example like this to receive incoming ascii but when
I'm receiving a hex dump, nothing displays.

Private Sub Form_Load()
server.LocalPort = 5890
server.Bind Winsock1.LocalPort
End Sub

Private Sub server_DataArrival(ByVal bytesTotal As Long)
Dim mydata As String
server.GetData mydata

Text1 = Text1 & mydata & vbCrLf
End Sub


I think it has something to do with this part of the code
Private Sub server_DataArrival(ByVal bytesTotal As Long)

Any help would be appreciated.



0
Comment
Question by:Bward323
  • 3
  • 3
  • 2
8 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 22614717
Try it this way instead:

    Private Sub server_DataArrival(ByVal bytesTotal As Long)
        Dim mydata As String
        server.GetData mydata, vbString
        Text1.Text = Text1.Text & mydata & vbCrLf
    End Sub

0
 

Author Comment

by:Bward323
ID: 22615322
for some reason I'm not getting anything. I added this line just to see when the event fires

msgbox "event fired " & mydata

and all I am getting in the msgbox is "event fir4ed"
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 22615631
=\

Are you getting a value in "bytesTotal"?

 Private Sub server_DataArrival(ByVal bytesTotal As Long)
        Dim mydata As String
        server.GetData mydata, vbString
        Debug.Print "DataArrival:"
        Debug.Print "bytesTotal = " & bytesTotal
        Debug.Print "mydata = " & mydata
    End Sub

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Bward323
ID: 22616518
Yes I am. The client is a GPRS device that I have send a test message....   "12345"
It sends this via UDP as a Hex Dump

The only thing I am seeing displayed on the screen is a message box that says,
 bytes total = 9
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 22616593
I'm not sure what's going wrong...and obviously I can't test it from here.  =(

I would start trouble shooting by starting with a fresh project and only the BARE BONES minimum code to receive a simple message and Debug.Print or MsgBox it.  This way you can determine if something else in your current project is possibly interfering...

0
 
LVL 3

Expert Comment

by:moonlight
ID: 22669175
Thanks Idle Mind for showing me this thread. Bward323, I have exactly the same problem:

http://www.experts-exchange.com/Programming/Languages/Winsock/Q_23796509.html#a22668967
0
 

Author Comment

by:Bward323
ID: 22886329
I found that the reason I was seeing  a string length  but nothing was showing up was that iit was a hex string.. I used this routine to convert from hex to ascii
Text1.text = HexString(strData)


Private Function HexString(EvalString As String) As String
Dim intStrLen As Integer
Dim intLoop As Integer
Dim strHex As String

EvalString = Trim(EvalString)
intStrLen = Len(EvalString)
For intLoop = 1 To intStrLen
strHex = strHex & " " & Hex(Asc(Mid(EvalString, intLoop, 1)))
Next
HexString = strHex

End Function
0
 
LVL 3

Accepted Solution

by:
moonlight earned 125 total points
ID: 22887415
yes it turned out it was two different things eventhough the same symptom. Glad you solved it too.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
allswap challenge 6 134
Capture logon name 13 106
pop out of webbrowser1 control vba6 5 44
"Failed to convert parameter value from a String to a Decimal." 4 33
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question