Solved

Someone Know about Chinese Operating System?

Posted on 2003-10-28
12
245 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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
 
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 28

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 28

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

740 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