Question Locked

Converstion from dec to hex

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Is there is function to send Hexadeciaml data to serial port in vb.

eg: &h65

i working with serial port communication with robots it take &h64 this value from textbox and then send the data back to me in the another text box,But i want that if user enter the decimal data then it should convert into this form &h64 and then send it to the serial port .
it convert the value to hexadecimal but when i pass this value to the mscomm control or to the serial port it doesn't reply my code is just follow below.
[code=vb]
Text3.Text = Hex(Text1.Text)
bytetosend(0) = Text3.Text
bytetosend(1) = Text3.Text
bytetosend(2) = Text3.Text
bytetosend(3) = Text3.Text
bytetosend(4) = Text3.Text
bytetosend(5) = Text3.Text
buffer = bytetosend()
MSComm1.Output = buffer
Do
dummy = DoEvents()
Loop Until MSComm1.InBufferCount > 5
datain = MSComm1.Input
Text2.Text = Val(Asc(Mid$(datain, 1, 1)))

[/code]
And i want to display the value in Text2.text from input from serial port.pls help in this .
Thank u

2 replies

by mdv3441

One thing you might try is to get rid of the DoEvents in your do loop. This will cause your program to miss an interrupt. I learned this the hard way.

This discussion is closed to new replies.