How to receive HEX data from Terminal to Visual Basic 2005?

I need to display on TextBox1

Page 1 of 1

2 Replies - 4687 Views - Last Post: 19 October 2007 - 11:10 AM Rate Topic: -----

#1 Wanxi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 16-October 07

How to receive HEX data from Terminal to Visual Basic 2005?

Posted 19 October 2007 - 02:32 AM

Hi everyone,

I'm doing a Visual Basic 2005 Application...


Purpose: (Please Read)
.To receive data from SerialPort1,
.Data is a Hex data..
.Sender is from a hardware.. but now temporary using --> Terminal v1.9b 20040204 Bary


My Question:
1) Can my Receiver TextBox1 receive Hex data and display Hex too??
2) Do i need to program vb to convert CHAR to HEX?
Eg. if receive HEX "0", then it will add 30.. to get DEC.. (Show in Dec also nevermind...)
*Note: Because vb will recognize the received Hex data as a Char...


Note:
1) Green is the things that will affect the receiving part..
2) The below is not the whole program.. But 90% is over here... the 10% just not important things...

My Program:
==========
Class Form1
Inherits Form
Public Delegate Sub MyDelegate(ByVal Buffer As String)
----------------------------------------------------------------------------
Private Sub Display(ByVal Buffer As String) 
*THE RECEIVED DATA WILL PUT INTO BUFFER, THAN BUFFER WILL PUT THE DATA TO TEXTBOX1

TextBox1.Text = Buffer

End Sub
----------------------------------------------------------------------------
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs) 
*SEND THE RECEIVED DATA TO DISPLAY

Me.BeginInvoke(New MyDelegate(AddressOf Display), SerialPort1.ReadLine())

End Sub
----------------------------------------------------------------------------
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load 
*WHEN FORM LOAD, LOAD AVAILABLE SERIAL COM PORT INTO COMBOBOX1

For i As Integer = 0 To My.Computer.Ports.SerialPortNames.Count - 1
ComboBox1.Items.Add(My.Computer.Ports.SerialPortNames(i))

Next
Try
SerialPort1.Open()
AddHandler SerialPort1.DataReceived, AddressOf SerialPort1_DataReceived

Catch ex As System.Exception
MessageBox.Show(ex.Message)
End Try

End Sub
======================================================================
Public Class ComPort 
*NOT IMPORTANT
Private _longName As String
Public Sub New(ByVal longName As String)
Me._longName = longName
End Sub
Public ReadOnly Property longName() As String
Get
Return Me._longName
End Get
End Property
End Class



Regards Wanxi

*Always use code blocks when posting your code :) Moving to the VB.Net Forum

This post has been edited by PsychoCoder: 19 October 2007 - 04:59 AM


Is This A Good Question/Topic? 0
  • +

Replies To: How to receive HEX data from Terminal to Visual Basic 2005?

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1632
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: How to receive HEX data from Terminal to Visual Basic 2005?

Posted 19 October 2007 - 05:04 AM

Did you even try the solution jayman9 gave you here? And why did you start a separate thread for the same exact question??
Was This Post Helpful? 0
  • +
  • -

#3 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: How to receive HEX data from Terminal to Visual Basic 2005?

Posted 19 October 2007 - 11:10 AM

Thread closed. Please refer to the topic you have already started if you have additional questions that need to be answered.

No need to create multiple threads on the same topic.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1