Welcome to Dream.In.Code
Become a VB Expert!

Join 149,385 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,316 people online right now. Registration is fast and FREE... Join Now!




Converting dec to hex from textbox and then sending to the serial por

 
Reply to this topicStart new topic

Converting dec to hex from textbox and then sending to the serial por, serial port

jatinder_44
7 May, 2007 - 04:49 AM
Post #1

New D.I.C Head
*

Joined: 2 May, 2007
Posts: 2


My Contributions
wink2.gif Hello to all
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 .
I have wrritten the code for it .
Here it's
vb
 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)))


And i want to display the value in Text2.text from input from serial port.pls help in this .
Thank u
User is offlineProfile CardPM
+Quote Post

born2c0de
RE: Converting Dec To Hex From Textbox And Then Sending To The Serial Por
7 May, 2007 - 11:45 PM
Post #2

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 4,026



Thanked: 38 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
I'm afraid VB6 has no direct Support for Serial Port Communication.
Try using some Serial Port VB API.

If I were you, I'd write the serial port code in C (maybe with assembly inserts, to use the OUT instruction), put it in a DLL File and call this function from VB.

--x--
Depending on what else you need to do with the serial port, you might need to use the DDK (Driver Development Kit) as well if you need direct access to the driver, as WINDOWS NT doesn't allow Applications outside ring 0 to access hardware directly.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 09:49AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month