Solved

Someone Know about Chinese Operating System?

Posted on 2003-10-28
12
238 Views
Last Modified: 2010-05-01
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.
0
Comment
Question by:AzraSound
  • 5
  • 4
  • 2
12 Comments
 
LVL 29

Expert Comment

by:leonstryker
ID: 9636591
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
 
LVL 28

Author Comment

by:AzraSound
ID: 9637230
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
 
LVL 29

Expert Comment

by:leonstryker
ID: 9637298
Maybe, and maybe they are trying to type something which just looks like a decimal point.
0
 
LVL 28

Author Comment

by:AzraSound
ID: 9779720
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
 
LVL 29

Expert Comment

by:leonstryker
ID: 9779846
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 29

Expert Comment

by:leonstryker
ID: 9779874
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
 
LVL 28

Author Comment

by:AzraSound
ID: 9779906
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
 
LVL 29

Expert Comment

by:leonstryker
ID: 9779937
AzraSound,

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

Leon
0
 
LVL 27

Accepted Solution

by:
Ark earned 500 total points
ID: 9970220
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
 
LVL 28

Author Comment

by:AzraSound
ID: 9972116
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
 
LVL 27

Expert Comment

by:Ark
ID: 9976187
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now