Reading a byte from GUI

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thiago777
    New Member
    • May 2007
    • 89

    Reading a byte from GUI

    Hello!

    How do you convert string to a single byte?

    For example, I have the following string:

    "10111010"

    I need to use that data (8 bits) to fill a byte.

    I tried like this:

    [code=vbnet]

    Public Shared Function StrToByteArray( ByVal str As String) As Byte()
    str = str.Substring(0 , 8)
    Dim encoding As New System.Text.ASC IIEncoding
    Return encoding.GetByt es(str)
    End Function 'StrToByteArray
    [/code]
    but it always returns 49

    what am I doing wrong?
    tnks in advance.
Working...