Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2008-09-30
8
Medium Priority
?
303 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: 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 500 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

609 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