RealBasic byte to string

667 views Asked by At

In RealBasic, is there a way to convert a byte to a string?

2

There are 2 answers

0
Andrew Lambert On

If you mean turn a Byte into a string representation of the byte in Binary (or hex or Octal), then:

  Dim x As Byte = 24  //For example
  Dim z, y, w As String
  y = Bin(x)      //Binary = "11000"
  z = Hex(x)      //Hexadecimal = "18"
  w = Oct(x)      //Octal = "30"
0
Paul Lefebvre On

You could use MemoryBlock:

  Dim m As MemoryBlock
  m = NewMemoryBlock(1)
  m.Byte(0) = 65
  MsgBox(m.StringValue(0, 1)) // Displays "A"

Of course, Chr(65) does the same thing...