Unicode Code Reader Function In Access

Unicode Code Reader Function In Access

Because the VBA environment does not support full Unicode, setting up the Unicode read function in Unicode as well as Excel is difficult. This article introduces a way to set up a digital read function using Unicode fonts in Access (you can also apply in Excel, VB ...). The steps are as follows:

Open the Access database.

Create a form named FormTam, on FormTam create two labels:

LabSo, enter the string: "no one two three four five six seven eight nine one hundred fifty ten", the end of the string has a space.

LabDonvi, enter the string: "copper. trillion, "the end of the string also has white space.

In the Module, click New to create a new module with the default name of Module1. Then click Design to enter the code editor and enter the following code:

Declare two global variables, which are two arrays containing string and unit strings, taken from LabSo and LabDonvi through the DocBook and Docdonvi procedures.

Public Solay (0 To 15) As String

Public Donvilay (0 To 4) As String

Private Sub Docchu () Get a series of numbers from LabSo placed in the Solay array

Dim tp, Stp, ii

ii = 0: tp = Form_FormTam.LabSo.Caption

Stp = InStr (tp, "")

Do While Stp & lt; & gt; 0

Solay (ii) = Left (tp, Stp)

tp = Right (tp, Len (tp) - Stp)

1Stp = InStr (tp, "")

ii = ii + 1

Loop

End Sub

Private Sub Docdonvi () Get unit strings from LabDonvi placed on the Donvilay array

Dim tp, Stp, ii

ii = 0: tp = Form_FormTam.LabDonvi.Caption

Stp = InStr (tp, "")

Do While Stp & lt; & gt; 0

Donvilay (ii) = Left (tp, Stp)

tp = Right (tp, Len (tp) - Stp)

Stp = InStr (tp, "")

ii = ii + 1

Loop

End Sub

Create a digital read function:

Public Function DocVND (Sodoc As String) As String

If Len (Sodoc) & gt; 12 Then

DocVND = "Through the cans through the cafeteria. Let's see! "
Exit Function
End If
Sodoc = Round (Sodoc, 0)
Dim Cht As String
Dim fg0 As Boolean
Dim fg1 As Boolean
Dim So As String
Dim ch As String
Dim tp As String
Dim and As Byte
Dim dv
Dim chs

Docchu Call the function of reading numbers
chs = solay
Docdonvi Call unit function
dv = Donvilay
By While Sodoc & lt; & gt; ""
Cht = ""
If Len (Sodoc) & lt; & gt; 0 Then
If (Len (Sodoc) & gt; = 3) Then
So = Right (Sodoc, 3)
Else
So = Right (Sodoc, Len (Sodoc))
End If
Sodoc = Left (Sodoc, Len (Sodoc) - Len (So))
And Left (So, 1) = "0" And (So, 2, 1) = "0"
ch = ch
Else
If Len (So) = 3 Then
If Left (So, 1) & lt; & gt; "Then
Cht = chs (Left (So, 1)) + chs (15)
End If
So = Right (So, 2)
End If
If Len (So) = 2 Then
If Left (So, 1) = "0" Then
If Right (So, 1) & lt; & gt; "0" Then
Cht = Cht + chs (11)
End If
fg0 = True
Else
If Left (So, 1) = "1" Then
Cht = Cht + chs (14)
Else
Cht = Cht + chs (Left (So, 1)) + chs (13)
fg1 = True
End If
End If
So = Right (So, 1)
End If
If Right (So, 1) & lt; & gt; 0 Then
If Left (So, 1) = "5" And Not fg0 Then
Nếu Len (tp) = 1 Then
Cht = Cht + chs (4)
Else
Cht = Cht + chs (12)
End If
Else
If Left (So, 1) = 1 And Not (Not fg1 Or fg0) And Cht & lt; & gt; "Then
Cht = Cht + chs (10)
Else
Cht = Cht + chs (Left (So, 1))
End If
End If
End If
ch = Cht + dv (i) + ch
End If
i = i + 1
End If
Loop
If Right (Trim (ch), 1) & lt; & gt; "Then
ch = ch + dv (0)
End If
DocVND = UCase (Left (ch, 1)) & amp; Mid (ch, 2)
End Function

I do not analyze the number reading function by TGVT.
4. Use the DocVND function
Create a textbox named Text1, right-click on Text1 and select Build Event, in Choose Builder, select Code Builder and click OK. Microsoft VB window appears, enter the following code:
Private Sub Text1_BeforeUpdate (Cancel As Integer)
Ketqua.Caption = DocVND (Text1.Text)
End Sub

Open the form, enter the numbers and hit enter, you will have the results as shown. Program source can be downloaded at website of TGVT - PCW VN.

Pham Van Trung
phamtrung03@yahoo.com