Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004

    Talking Unanswered: detect string is japanese, not english

    Hi all,
    Suppose that on "A" form, I have 2 textboxes: "English" and "Japanese".
    On "English" textbox will be inputted English string only, and "Japanese"
    textbox will be inputted Japanese stirng only.
    But in some case, my users input Japanese string into English textbox by mistake.
    Could anyone give me some code to insert into before update event to check
    wether user in input to correct textbox?
    Pls help me. I need your help.
    Many thanks.

  2. #2
    Join Date
    Mar 2005
    Last edited by waynephillips; 01-21-06 at 03:29.

  3. #3
    Join Date
    Mar 2005
    Probably the easiest solution would be to check if the string fits into the normal ASCII character set.

    I've wrote a quick function for you:

    Function IsASCIIString(strValue As String) As Boolean
        ' Written by Wayne Phillips, 21/01/2006
        ' Free to use
        Dim i As Long
        Dim lngLength As Long
        Dim blnRetVal As Boolean
        Dim intUnicodeValue As Integer
        'Length in characters
        lngLength = Len(strValue)
        For i = 1 To lngLength
            intUnicodeValue = AscW(Mid(strValue, i, 1))
            If intUnicodeValue < 0 Or _
                intUnicodeValue > 127 Then
                IsASCIIString = False
                Exit Function
            End If
        'No non-ASCII characters were found.
        IsASCIIString = True
    End Function
    Then, in your form code you can test like this:

        If Len(TextBoxName) > 0 Then
            If Not IsASCIIString(TextBoxName) Then
                MsgBox "You entered non-ASCII characters!"
            End If
        End If
    Last edited by waynephillips; 01-21-06 at 03:30.

  4. #4
    Join Date
    Mar 2005
    Hmmm, not sure what is wrong with the forum today... I posted the reply, but the main page still shows 0 replies.

    EDIT: This post fixed it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts