I am new to VB6 and I would like to convert a parameter from Double to Hex for Chinese Unicode values. The issue here is for input values of range 1-127, the output is the same. For values beyond 127, the output is 63 (seen as a ?). The parameter is 4 bytes long.
This happens despite using ChrW. My computer has been set to Chinese Simplified under System Locale. Is there a way to overcome this?
Dim sHex As String
Dim sTmp As String
Dim n As Integer
Dim m As Integer
Dim sRet As String
Dim nByteCountMerk As Integer
Public Function ConvDoubleToHexString(dVal As Double, ByVal nByteCount As Integer) As String
m = 1
sHex = Hex(dVal)
nByteCountMerk = nByteCount
If nByteCount < Len(sHex) / 2 Then nByteCount = Len(sHex) / 2
If nByteCount < 1 Then nByteCount = 1
sHex = String(nByteCount * 2 - Len(sHex), "0") & sHex
For n = 0 To nByteCount - 1
sTmp = ChrW(Val("&H" & Mid(sHex, m, 2)))
m = m + 2
sRet = sRet & sTmp
next n
End Function