Solved

Someone Know about Chinese Operating System?

Posted on 2003-10-28
12
235 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

759 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

22 Experts available now in Live!

Get 1:1 Help Now