473,387 Members | 3,684 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

rs232

Lou
How do i convert a string to bytes?
I want to send raw bytes out the serial control.

Private Sub Rs232SendData(ByVal cmd As String)

Try

cmd=cmd & vbCrLf

'Convert it to byte data here

?????????????????????????

SerialPort1.Write(byteData)

txtData.AppendText(Now.ToShortTimeString & "->Sent: " & cmd)

Catch ex As System.Exception

MessageBox.Show(ex.Message)

End Try

End Sub
-Lou
Jun 2 '07 #1
3 1305
"Lou" <lo********@comcast.netwrote in news:#Rfx6YTpHHA.3968
@TK2MSFTNGP06.phx.gbl:
How do i convert a string to bytes?
Depending on what encoding you're using (ASCII in this case):

System.Text.ASCIIEncoding.ASCII.GetBytes(MyStringH ere)

If it's another encoding type, swap ASCIIEncoding with the other classes.
Jun 2 '07 #2
Lou,

Maybe this page gives an explanation

http://msdn2.microsoft.com/en-us/library/ms172828.aspx

Use only ASCII if you are sure that you are only the 7 less significant
bites from a byte (127bits) as ASCII is only for that. It is using in a lot
of countries different code pages and gives therefore different results as
it is used in that if it is about the full byte.

Cor

"Lou" <lo********@comcast.netschreef in bericht
news:%2****************@TK2MSFTNGP06.phx.gbl...
How do i convert a string to bytes?
I want to send raw bytes out the serial control.

Private Sub Rs232SendData(ByVal cmd As String)

Try

cmd=cmd & vbCrLf

'Convert it to byte data here

?????????????????????????

SerialPort1.Write(byteData)

txtData.AppendText(Now.ToShortTimeString & "->Sent: " & cmd)

Catch ex As System.Exception

MessageBox.Show(ex.Message)

End Try

End Sub
-Lou

Jun 2 '07 #3
Lou
Thanks everyone..

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
Lou,

Maybe this page gives an explanation

http://msdn2.microsoft.com/en-us/library/ms172828.aspx

Use only ASCII if you are sure that you are only the 7 less significant
bites from a byte (127bits) as ASCII is only for that. It is using in a
lot of countries different code pages and gives therefore different
results as it is used in that if it is about the full byte.

Cor

"Lou" <lo********@comcast.netschreef in bericht
news:%2****************@TK2MSFTNGP06.phx.gbl...
>How do i convert a string to bytes?
I want to send raw bytes out the serial control.

Private Sub Rs232SendData(ByVal cmd As String)

Try

cmd=cmd & vbCrLf

'Convert it to byte data here

?????????????????????????

SerialPort1.Write(byteData)

txtData.AppendText(Now.ToShortTimeString & "->Sent: " & cmd)

Catch ex As System.Exception

MessageBox.Show(ex.Message)

End Try

End Sub
-Lou


Jun 2 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dan | last post by:
I wnat to see in browser an status from an device connected on rs232 port The java class for read from serial port is: //Serial.java import java.io.*; import java.util.*; import...
4
by: nchap99 | last post by:
hello, Does anybody know if Microsoft Dot Net supports the RS232 type of connection. As far as I know Visual basic 6 supports RS232 connection format. Thanks,
6
by: Przemo | last post by:
Hi, Do you know some good RS232C class? There is one in VB.NET 101 Examples, but I think it is poor. 1. I can't for e.g. read into my application all data received. I must tell how many...
2
by: AlirezaH | last post by:
Any sample program for rs232 communication?
0
by: Jason T | last post by:
I've downloaded and installed the '101 Visual Basic and C# Code Samples' from http://www.microsoft.com/downloads/details.aspx?familyid=08e3d5f8-033d-420b-a3b1-3074505c03f3&displaylang=en I have...
8
by: Terry Olsen | last post by:
I'm trying to use the RS232 class that was in the Platform SDK (i think). Has anyone else used this with events successfully? Here's what i've got: ====================== Public WithEvents...
13
by: jay.dow | last post by:
I want to write to the pins of an RS232 without using the serial protocol. The use would be every pin could act to complete a circuit in customized hardware. I could use python to communicate...
4
by: Dave Harry | last post by:
I found the RS232 class from MS's 101 VB samples. Writing to the port works fine. (I've got hyperterminal on the other comm port and a crossover cable between COM1 and COM2) The port is opened...
6
by: Henning M | last post by:
Hi all, Im trying to send a command to my uprocessor project, but when i try to read the answer for the uPU I get the same commed I just send to it??? It is as if the command isn't send before I...
3
by: ad | last post by:
I am using VS2005 to develop Web application. How can I receive the data from RS232 of client's computer?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.