-1

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
Arjun
  • 9
  • 1
  • 7
  • did you read the [Tutorial Using Unicode in Visual Basic 6.0](http://www.cyberactivex.com/UnicodeTutorialVb.htm)? – deblocker May 16 '17 at 15:13

1 Answers1

-1

You will have to change the "Language for non Unicode Programs" in the control panel.

I have written some notes about this problem here. These notes are old, with screen shots from Windows XP, but I'm pretty sure that the identical setting still exists.

The problem is that VB6 is only partly Unicode based. Internally all strings are Unicode, but the build in controls and menus are not.

Phil Jollans
  • 3,605
  • 2
  • 37
  • 50