byte to char
tnx
If you know the characters are ASCII then the following should work.
Public Function AsciiByteToChar(ByVal b As Byte) As CharDim barr() As Byte = New Byte() {b}Dim carr() As Char = Encoding.ASCII.GetChars(barr)Return carr(0)End Function
jayson.ws.ds2.ci.ftsp wrote:
in vb6..Asc("A")
will return 65.. is this what you need?
I'm a tad confused, but isn't he looking to convert the byte to the character in which case didn't VB have a Chr() and Chr$() function to do that ... eg Chr(65) = "A".
The obvious thing here is that the byte value must contain the ASCII value for the character .... perhaps your value is encoded to something else?
In order to interpret special characters (such as norwegian special letters), I use the Chr() function to convert a byte to a char.
Example code:
'Create a file stream
Dim fi As New FileInfo("input.txt")
Dim fs As FileStream = fi.OpenRead()
Dim bytChar As Byte
Dim strChar as String
bytChar = fs.ReadByte
strChar = Chr(bytChar)
Hi,
See too please my reply at >>
Hope you find some of them useful?
Regards,
S_DS