You are on page 1of 1

Private Sub Command1_Click()

End
End Sub
Private Sub Form_Load()
Text1 = 0
Text2 = ""
Text2.Appearance = 0
Text2.Enabled = False
Command1.Caption = "&Close"
End Sub
Private Sub Text1_Change()
Dim lenMax As Integer, i As Byte, Satang As String, Baht As String
lenMax = Len(Text1.Text)
For i = 1 To lenMax
If Mid(Text1.Text, i, 1) = "." Then
Satang = Right(Text1.Text, lenMax - i)
Baht = Left(Text1.Text, i - 1)
Exit For
Else
Baht = Left(Text1.Text, i)
End If
Next
If Baht <> "" Then Text2 = changenum(Baht) & ""
If Satang <> "" Then Text2 = Text2 & changenum(Satang) & _
IIf(changenum(Satang) <> "", "", "")
End Sub

Function changenum(num As String) As String


Dim i As Integer, max As Integer, r As String, n As String
num = Trim(Str(Val(num)))
max = Len(num)
For i = 1 To max
r = Choose(((max - i + 1) Mod 6) + 1, "", "", "", "", "", "")
n = Choose(Mid(num, i, 1) + 1, "", "", "", "", "", "", "", "
If r = "" And n = "" Then n = ""
If n = "" And r = "" And max <> 1 Then n = ""
If i = 1 And n = "" And max > 1 Then n = ""
If r = "" And n = "" Then n = ""
If r = "" And max - i + 1 > 6 Then r = ""
If n <> "" Then
changenum = changenum & n & r
Else
If r = "" Then changenum = changenum & r
End If
Next
End Function

You might also like