Code: Select all
'merging 2 Binary strings to convert 2 Bytes into 1 Byte
'no magic here the 4 bit numbers have to be in a range of 0 - 15
Dim As String binary1,binary2,binary3
Dim As UByte decimalnumber
'binary1 = 7 binary2 = 8 merged this should be 78 in Hexadecimal
binary1 = "00000111":binary2 = "00001000"
'remove 4 zero's from each string and merge them together
binary3 = right(binary1,4) + right(binary2,4)
print "strings merged ";binary3
'convert binary string to a decimal number
decimalnumber = val(str("&B" + binary3))
print "decimal value = ";decimalnumber
print "Hex Value = ";Hex(decimalnumber)
'now the decimal number can be written to a file using Put #f,,decimalnumber
'this will save storage space