Public Function Digital(ByVal AMOUNT As Double, FLAGTYPE As String)
On Error Resume Next
Select Case FLAGTYPE
Case "EGYPT"
LE = " جنيها "
P = " قرشا "
PS = " قروش "
POUNDS = " جنيهات "
V = Int(Math.Abs(AMOUNT))
VPS = Val(Right(Format(AMOUNT, "000000000000.00"), 2))
WORDINTEGER = AmountWord(V)
WORDPS = AmountWord(VPS)
If WORDINTEGER <> "" And (VPS <= 2) Then Result = WORDINTEGER & LE & " و " & WORDPS & P & "فقط لاغير "
If WORDINTEGER <> "" And (VPS >= 3 And VPS <= 9) Then Result = WORDINTEGER & LE & " و " & WORDPS & PS & "فقط لاغير "
If WORDINTEGER <> "" And (VPS > 9) Then Result = WORDINTEGER & LE & " و " & WORDPS & P & "فقط لاغير "
If WORDINTEGER = "" And (VPS <= 2) Then Result = WORDPS & P & "فقط لاغير "
If WORDINTEGER = "" And (VPS >= 3 And VPS <= 9) Then Result = WORDPS & PS & "فقط لاغير "
If WORDINTEGER = "" And VPS > 9 Then Result = WORDPS & P & "فقط لاغير "
If WORDINTEGER = "" And VPS = 0 Then Result = ""
If WORDINTEGER <> "" And VPS = 0 Then Result = WORDINTEGER & LE & "فقط لاغير "
Digital = Result
Case "USA"
DOLLAR = " دولار "
SENT = " سنتاً "
SENTS = "سنتات"
V = Int(Math.Abs(AMOUNT))
VPS = Val(Right(Format(AMOUNT, "000000000000.00"), 2))
WORDINTEGER = AmountWord(V)
WORDPS = AmountWord(VPS)
If WORDINTEGER <> "" And (VPS <= 2) Then Result = WORDINTEGER & DOLLAR & " و " & WORDPS & SENT & "فقط لاغير "
If WORDINTEGER <> "" And (VPS >= 3 And VPS <= 9) Then Result = WORDINTEGER & DOLLAR & " و " & WORDPS & " " & SENTS & " " & "فقط لاغير "
If WORDINTEGER <> "" And (VPS > 9) Then Result = WORDINTEGER & DOLLAR & " و " & WORDPS & SENT & "فقط لاغير "
If WORDINTEGER = "" And (VPS <= 2) Then Result = WORDPS & SENT & "فقط لاغير "
If WORDINTEGER = "" And (VPS >= 3 And VPS <= 9) Then Result = WORDPS & " " & SENTS & " " & "فقط لاغير "
If WORDINTEGER = "" And VPS > 9 Then Result = WORDPS & SENT & "فقط لاغير "
If WORDINTEGER = "" And VPS = 0 Then Result = ""
If WORDINTEGER <> "" And VPS = 0 Then Result = WORDINTEGER & DOLLAR & "فقط لاغير "
Digital = Result
Case "WEIGHT"
TON = " طن "
KG = " كيلو جرام "
KGS = "كيلو جرامات"
V = Int(Math.Abs(AMOUNT))
VPS = Val(Right(Format(AMOUNT, "000000000000.000"), 3))
WORDINTEGER = AmountWord(V)
WORDPS = AmountWord(VPS)
If WORDINTEGER <> "" And (VPS <= 2) Then Result = WORDINTEGER & TON & " و " & WORDPS & KG & "فقط لاغير "
If WORDINTEGER <> "" And (VPS >= 3 And VPS <= 9) Then Result = WORDINTEGER & TON & " و " & WORDPS & KGS & "فقط لاغير "
If WORDINTEGER <> "" And (VPS > 9) Then Result = WORDINTEGER & TON & " و " & WORDPS & KG & "فقط لاغير "
If WORDINTEGER = "" And (VPS <= 2) Then Result = WORDPS & KG & "فقط لاغير "
If WORDINTEGER = "" And (VPS >= 3 And VPS <= 9) Then Result = WORDPS & KGS & "فقط لاغير "
If WORDINTEGER = "" And VPS > 9 Then Result = WORDPS & KG & "فقط لاغير "
If WORDINTEGER = "" And VPS = 0 Then Result = ""
If WORDINTEGER <> "" And VPS = 0 Then Result = WORDINTEGER & TON & "فقط لاغير "
Digital = Result
End Select
End Function
Public Function AmountWord(ByVal AMOUNT As Double)
On Error Resume Next
n = Int(AMOUNT)
c = Format(n, "000000000000")
C1 = Val(Mid(c, 12, 1))
Select Case C1
Case Is = 1: str1 = "واحد"
Case Is = 2: str1 = "اثنان"
Case Is = 3: str1 = "ثلاثة"
Case Is = 4: str1 = "اربعة"
Case Is = 5: str1 = "خمسة"
Case Is = 6: str1 = "ستة"
Case Is = 7: str1 = "سبعة"
Case Is = 8: str1 = "ثمانية"
Case Is = 9: str1 = "تسعة"
End Select
C2 = Val(Mid(c, 11, 1))
Select Case C2
Case Is = 1: str2 = "عشر"
Case Is = 2: str2 = "عشرون"
Case Is = 3: str2 = "ثلاثون"
Case Is = 4: str2 = "اربعون"
Case Is = 5: str2 = "خمسون"
Case Is = 6: str2 = "ستون"
Case Is = 7: str2 = "سبعون"
Case Is = 8: str2 = "ثمانون"
Case Is = 9: str2 = "تسعون"
End Select
If str1 <> "" And C2 > 1 Then str2 = str1 + " و" + str2
If str2 = "" Then str2 = str1
If C1 = 0 And C2 = 1 Then str2 = str2 + "ة"
If C1 = 1 And C2 = 1 Then str2 = "احدى عشر"
If C1 = 2 And C2 = 1 Then str2 = "اثنى عشر"
If C1 > 2 And C2 = 1 Then str2 = str1 + " " + str2
C3 = Val(Mid(c, 10, 1))
Select Case C3
Case Is = 1: str3 = "مائة"
Case Is = 2: str3 = "مئتان"
Case Is > 2: str3 = Left(AmountWord(C3), Len(AmountWord(C3)) - 1) + "مائة"
End Select
If str3 <> "" And str2 <> "" Then str3 = str3 + " و" + str2
If str3 = "" Then str3 = str2
C4 = Val(Mid(c, 7, 3))
Select Case C4
Case Is = 1: str4 = "الف"
Case Is = 2: str4 = "الفان"
Case 3 To 10: str4 = AmountWord(C4) + " آلاف"
Case Is > 10: str4 = AmountWord(C4) + " الف"
End Select
If str4 <> "" And str3 <> "" Then str4 = str4 + " و" + str3
If str4 = "" Then str4 = str3
C5 = Val(Mid(c, 4, 3))
Select Case C5
Case Is = 1: str5 = "مليون"
Case Is = 2: str5 = "مليونان"
Case 3 To 10: str5 = AmountWord(C5) + " ملايين"
Case Is > 10: str5 = AmountWord(C5) + " مليون"
End Select
If str5 <> "" And str4 <> "" Then str5 = str5 + " و" + str4
If str5 = "" Then str5 = str4
C6 = Val(Mid(c, 1, 3))
Select Case C6
Case Is = 1: str6 = "مليار"
Case Is = 2: str6 = "ملياران"
Case Is > 2: str6 = AmountWord(C6) + " مليار"
End Select
If str6 <> "" And str5 <> "" Then str6 = str6 + " و" + str5
If str6 = "" Then str6 = str5
AmountWord = str6
End Function
ترفبوا شرح واستعمالات الكود إن شاء الله.