Noname > 26-08-10, 12:54 AM
Public Solay(0 To 15) As String
Public Donvilay(0 To 4) As String
Private Sub Docchu() 'Lấy chuỗi chữ số từ LabSo đặt vào mảng Solay
Dim tp, Stp, ii
ii = 0: tp = Form_FormTam.LabSo.Caption
Stp = InStr(tp, “ “)
Do While Stp <> 0
Solay(ii) = Left(tp, Stp)
tp = Right(tp, Len(tp) - Stp)
1Stp = InStr(tp, “ “)
ii = ii + 1
Loop
End Sub
Private Sub Docdonvi() 'Lấy chuỗi đơn vị từ LabDonvi đặt vào mảng Donvilay
Dim tp, Stp, ii
ii = 0: tp = Form_FormTam.LabDonvi.Caption
Stp = InStr(tp, “ “)
Do While Stp <> 0
Donvilay(ii) = Left(tp, Stp)
tp = Right(tp, Len(tp) - Stp)
Stp = InStr(tp, “ “)
ii = ii + 1
Loop
End Sub
Public Function DocVND(Sodoc As String) As String
If Len(Sodoc) > 12 Then
DocVND = “So qua lon qua hang tram ty. Hay xem lai!”
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 i As Byte
Dim dv
Dim chs
Docchu Gọi hàm đọc chữ số
chs = Solay
Docdonvi Gọi hàm đọc đơn vị
dv = Donvilay
Do While Sodoc <> “”
Cht = “”
If Len(Sodoc) <> 0 Then
If (Len(Sodoc) >= 3) Then
So = Right(Sodoc, 3)
Else
So = Right(Sodoc, Len(Sodoc))
End If
Sodoc = Left(Sodoc, Len(Sodoc) - Len(So))
If Left(So, 1) = “0” And Mid(So, 2, 1) = “0” And Right(So, 1) = “0” Then
ch = ch
Else
If Len(So) = 3 Then
If Left(So, 1) <> “ “ 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) <> “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) <> 0 Then
If Left(So, 1) = “5” And Not fg0 Then
If 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 <> “” 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) <> “.” Then
ch = ch + dv(0)
End If
DocVND=UCase(Left(ch, 1))&Mid(ch,2)
End Function
Private Sub Text1_BeforeUpdate(Cancel As Integer)
Ketqua.Caption = DocVND(Text1.Text)
End Sub