HI
I am writing an app which sends message to server/client and display them in the rich text box. All the messages send and recieved are displyed in Hex . Each line should display 16 hex pairs with their starting and end index(in 4 digit hex). I can display the starting and ending index in decimal but conversion to Hex cause apps to display error
Current
********************
Text: "This is a test for displaying index in decimal and it appears to be working"
Hex:
0000-0015 54 68 69 73 20 69 73 20 61 20 74 65 73 74 20 66
0016-0031 6F 72 20 64 69 73 70 6C 61 79 69 6E 67 20 69 6E
0032-0047 64 65 78 20 69 6E 20 64 65 63 69 6D 61 6C 20 61
0048-0063 6E 64 20 69 74 20 61 70 70 65 61 72 73 20 74 6F
0064-0073 20 62 65 20 77 6F 72 6B 69 6E 67
**********************
Should be
**********************
0000-000F 54 68 69 73 20 69 73 20 61 20 74 65 73 74 20 66
0010-001F 6F 72 20 64 69 73 70 6C 61 79 69 6E 67 20 69 6E
0020-002F 64 65 78 20 69 6E 20 64 65 63 69 6D 61 6C 20 61
0030-003F 6E 64 20 69 74 20 61 70 70 65 61 72 73 20 74 6F
0040-004B 20 62 65 20 77 6F 72 6B 69 6E 67
**********************
anyone have an idea how to do Hex addition and decimal to Hex (4 digit ) conversion.
Thanks
SC
Private Sub Command1_Click()
MsgBox ConvertAddToHex(32, 15) 'execute. In this sample the result would be 002F
End Sub
Private Function ConvertAddToHex(ByVal fnMyDec As Long, fnDecToAdd As Long) As String
Dim x As String, y As String
x = Hex(fnMyDec + fnDecToAdd) 'calculate and convert to Hex
y = Len(x)
ConvertAddToHex = String(4 - y, "0") & x 'add zeros up to four places
End Function
S