Solved

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

Posted on 2008-09-30
8
290 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 85

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 85

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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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 85

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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How does CurrentUser work? 10 37
Getting warning: You are about to delete 1 row(s) 9 50
Problem to App 4 83
Reccomended programming language for client-server applications 12 100
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

823 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