Someone Know about Chinese Operating System?

I need someone who can help me, preferably who runs a Chinese version of Windows, but anyone with experience with this is more than welcome to share.  I have a program that uses the following function in the KeyPress event of various control's throughout the project:


Public Function ValidateNumericEntry(ctl As Control, KeyAscii As Integer) As Integer
    On Error Resume Next
   
    With ctl
        If ((InStr(1, .Text, p_strDecimal) <> 0 And Chr(KeyAscii) = p_strDecimal And _
            InStr(1, .SelText, p_strDecimal) = 0) Or _
            (InStr(1, .Text, "-") <> 0 And Chr(KeyAscii) = "-") Or _
            (Chr(KeyAscii) = "-" And .SelStart <> 0)) Then
           
            'do not allow this key entry
            ValidateNumericEntry = 0
        Else
            'return original value
            If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 8 And _
                    Chr(KeyAscii) <> p_strDecimal And Chr(KeyAscii) <> "-" Then
                ValidateNumericEntry = 0
            Else
                ValidateNumericEntry = KeyAscii
            End If
        End If
    End With
End Function



We recently got a customer in China who says they cannot enter a decimal in the textboxes on the forms.  The p_strDecimal variable in the above function corresponds to the user's regional settings and what they use as a decimal.  I understand Chinese use a decimal point, same as the United States.  So, any ideas?  I thought it may have something to do with their double-byte character set but nothing above seems it should be an issue with regards to that, but, I could be wrong.
LVL 28
AzraSoundAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leonstrykerCommented:
See if you can find out what is the ASCII code for the deciamal point they are using and compare it with the expected value.
0
AzraSoundAuthor Commented:
They dont have a different ASCII value for the decimal point though do they?  I thought the first 255 or so characters in the ASCII chart were universal...
0
leonstrykerCommented:
Maybe, and maybe they are trying to type something which just looks like a decimal point.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

AzraSoundAuthor Commented:
I sent a debugging app to them and there decimal is the same as ours (he is pressing the right key).  I tried changing the Option Compare option, but nothing seems to allow the decimal through using the validation routine above.
0
leonstrykerCommented:
Ok, lets try to untangle this a bit.  Lets break out this statement to see which part is failing, there may be a problem with logic of the syntax:

Change:
If ((InStr(1, .Text, p_strDecimal) <> 0 And Chr(KeyAscii) = p_strDecimal And InStr(1, .SelText, p_strDecimal) = 0) Or (InStr(1, .Text, "-") <> 0 And Chr(KeyAscii) = "-") Or (Chr(KeyAscii) = "-" And .SelStart <> 0))

To:
intPart1 = InStr(1, .Text, p_strDecimal)
intPart2 = InStr(1, .SelText, p_strDecimal)
intPart3 = InStr(1, .Text, "-")

If (intPart1 <> 0 And Chr(KeyAscii) = p_strDecimal And intPart2  = 0) Or intPart3 <> 0 And Chr(KeyAscii) = "-") Or (Chr(KeyAscii) = "-" And .SelStart <> 0)) Then

In fact for testing you may wish to get rid of the check for dash to make it less complex
intPart1 = InStr(1, .Text, p_strDecimal)
intPart2 = InStr(1, .SelText, p_strDecimal)

If (intPart1 <> 0 And Chr(KeyAscii) = p_strDecimal And intPart2  = 0)) Then


Leon



0
leonstrykerCommented:
By the way, I know for a fact that Russian uses a comma as their decimal seperator, but I am not sure about Chinese.  Just something to keep in mind.

Leon
0
AzraSoundAuthor Commented:
The logic is fine, as it has worked everywhere else (this program is used in Russia, South America, North America, China, Egypt, etc.).  In fact, it works on some versions of the Chinese operating system, but apparently, not this particular one.  What the difference is between this system and the other Chinese system it worked on, I will have to investigate to find out.
0
leonstrykerCommented:
AzraSound,

Let me know what you find.  Sorry I could not be of more help.

Leon
0
ArkCommented:
Hello Tony.
Did you try to let OS do all job itself, smth like this:
If CStr(CDbl(.Text)) = .Text Then ValidateNumericEntry = KeyAscii Else ValidateNumericEntry = 0

Regards
Ark
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AzraSoundAuthor Commented:
Thanks Ark, it does simplify things, especially with regards to their regional settings and what they use as their decimal separator.  With some added error handling (e.g., the text is empty, just a decimal, or just the negative sign) this could probably work as well.  For now, the client was happy with us just removing the validation code altogether (if they enter text instead of a number, they understand the calculations won't work).  However, thanks for that input, as it probably solves the problem since I think the issue is related to one of those internal VB functions such as Instr.
0
ArkCommented:
Hello again. I also think so, though it's strange because VB works with OLE strings (BSTR) which are internally unicode. I used CDbl in my programs - it correctly transfer strings irrespectivly to local decimal separator (as leonstryker mentioned above in Russia comma is using as decimal separator though I prefer point). Anyway I'm afraid you'll have to use API instead of VB Instr (BTW, have a look on SHLWAPI - there are StrStr/StrStrI and StrCSpn/StrCSpnI

'From MSDN:
Private Declare Function StrCSpn Lib "Shlwapi" _
   Alias "StrCSpnW" (ByVal lpStr As Long, _
   ByVal lpSet As Long) As Long
 
Private Declare Function StrCSpnI Lib "Shlwapi" _
   Alias "StrCSpnW" (ByVal lpStr As Long, _
   ByVal lpSet As Long) As Long
 
Public Function InstrAny(SearchString As String, _
  CharList As String, _
   Optional CaseSensitive As Boolean = True) As Long
 
  ' Returns the position of the first occurrence of
  ' a character in CharList within SearchString.
  If CaseSensitive Then
    nRet = StrCSpn(StrPtr(SearchString), StrPtr(CharList))
  Else
    nRet = StrCSpnI(StrPtr(SearchString), StrPtr(CharList))
  End If
  Select Case nRet
    Case 0, Len(SearchString)
      InstrAny = 0
    Case Else
      InstrAny = nRet + 1
  End Select
End Function
 
Public Function ContainsAnyChar(
   ByVal SearchString As String, CharList As String, _
   Optional CaseSensitive As Boolean = True) As Boolean
 
  ' Returns True if SearchString contains any
  ' character in CharList.
  ContainsAnyChar = CBool(InstrAny(SearchString, _
    CharList, CaseSensitive))
End Function

Regards
Ark
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.