Imports Microsoft.VisualBasic
Imports System
Public Class Conversion
Dim Ma, Mi, N, B, R As String
Dim result As String
Public Function BADRMEDIA(ByVal X As Double) As String
Ma = " ريا ل"
Mi = " هلله"
N = Int(X)
B = Val(Right(Format(X, "000000000000.00"), 2))
R = SFormatNumber(N)
If R <> "" And B > 0 Then result = R & Ma & " و " & B & Mi
If R <> "" And B = 0 Then result = R & Ma
If R = "" And B <> 0 Then result = B & Mi
BADRMEDIA = result
End Function
Public Function SFormatNumber(ByVal X As Double) As String
Dim letter1 As String = String.Empty
Dim letter2 As String = String.Empty
Dim letter3 As String = String.Empty
Dim letter4 As String = String.Empty
Dim letter5 As String = String.Empty
Dim letter6 As String = String.Empty
Dim c As String = Format(Math.Floor(X), "000000000000")
Dim C1 As Double = Val(Mid(c, 12, 1))
Select Case C1
Case Is = 1 : letter1 = "واحد"
Case Is = 2 : letter1 = "اثنان"
Case Is = 3 : letter1 = "ثلاثة"
Case Is = 4 : letter1 = "اربعة"
Case Is = 5 : letter1 = "خمسة"
Case Is = 6 : letter1 = "ستة"
Case Is = 7 : letter1 = "سبعة"
Case Is = 8 : letter1 = "ثمانية"
Case Is = 9 : letter1 = "تسعة"
End Select
Dim C2 As Double = Val(Mid(c, 11, 1))
Select Case C2
Case Is = 1 : letter2 = "عشر"
Case Is = 2 : letter2 = "عشرون"
Case Is = 3 : letter2 = "ثلاثون"
Case Is = 4 : letter2 = "اربعون"
Case Is = 5 : letter2 = "خمسون"
Case Is = 6 : letter2 = "ستون"
Case Is = 7 : letter2 = "سبعون"
Case Is = 8 : letter2 = "ثمانون"
Case Is = 9 : letter2 = "تسعون"
End Select
If letter1 <> "" And C2 > 1 Then letter2 = letter1 + " و" + letter2
If letter2 = "" Or letter2 Is Nothing Then
letter2 = letter1
End If
If C1 = 0 And C2 = 1 Then letter2 = letter2 + "ة"
If C1 = 1 And C2 = 1 Then letter2 = "احدى عشر"
If C1 = 2 And C2 = 1 Then letter2 = "اثنى عشر"
If C1 > 2 And C2 = 1 Then letter2 = letter1 + " " + letter2
Dim C3 As Double = Val(Mid(c, 10, 1))
Select Case C3
Case Is = 1 : letter3 = "مائة"
Case Is = 2 : letter3 = "مئتان"
Case Is > 2 : letter3 = Left(SFormatNumber(C3), Len(SFormatNumber(C3)) - 1) + "مائة"
End Select
If letter3 <> "" And letter2 <> "" Then letter3 = letter3 + " و" + letter2
If letter3 = "" Then letter3 = letter2
Dim C4 As Double = Val(Mid(c, 7, 3))
Select Case C4
Case Is = 1 : letter4 = "الف"
Case Is = 2 : letter4 = "الفان"
Case 3 To 10 : letter4 = SFormatNumber(C4) + " آلاف"
Case Is > 10 : letter4 = SFormatNumber(C4) + " الف"
End Select
If letter4 <> "" And letter3 <> "" Then letter4 = letter4 + " و" + letter3
If letter4 = "" Then letter4 = letter3
Dim C5 As Double = Val(Mid(c, 4, 3))
Select Case C5
Case Is = 1 : letter5 = "مليون"
Case Is = 2 : letter5 = "مليونان"
Case 3 To 10 : letter5 = SFormatNumber(C5) + " ملايين"
Case Is > 10 : letter5 = SFormatNumber(C5) + " مليون"
End Select
If letter5 <> "" And letter4 <> "" Then letter5 = letter5 + " و" + letter4
If letter5 = "" Then letter5 = letter4
Dim C6 As Double = Val(Mid(c, 1, 3))
Select Case C6
Case Is = 1 : letter6 = "مليار"
Case Is = 2 : letter6 = "ملياران"
Case Is > 2 : letter6 = SFormatNumber(C6) + " مليار"
End Select
If letter6 <> "" And letter5 <> "" Then letter6 = letter6 + " و" + letter5
If letter6 = "" Then letter6 = letter5
SFormatNumber = letter6
End Function
End Class
Imports System
Public Class Conversion
Dim Ma, Mi, N, B, R As String
Dim result As String
Public Function BADRMEDIA(ByVal X As Double) As String
Ma = " ريا ل"
Mi = " هلله"
N = Int(X)
B = Val(Right(Format(X, "000000000000.00"), 2))
R = SFormatNumber(N)
If R <> "" And B > 0 Then result = R & Ma & " و " & B & Mi
If R <> "" And B = 0 Then result = R & Ma
If R = "" And B <> 0 Then result = B & Mi
BADRMEDIA = result
End Function
Public Function SFormatNumber(ByVal X As Double) As String
Dim letter1 As String = String.Empty
Dim letter2 As String = String.Empty
Dim letter3 As String = String.Empty
Dim letter4 As String = String.Empty
Dim letter5 As String = String.Empty
Dim letter6 As String = String.Empty
Dim c As String = Format(Math.Floor(X), "000000000000")
Dim C1 As Double = Val(Mid(c, 12, 1))
Select Case C1
Case Is = 1 : letter1 = "واحد"
Case Is = 2 : letter1 = "اثنان"
Case Is = 3 : letter1 = "ثلاثة"
Case Is = 4 : letter1 = "اربعة"
Case Is = 5 : letter1 = "خمسة"
Case Is = 6 : letter1 = "ستة"
Case Is = 7 : letter1 = "سبعة"
Case Is = 8 : letter1 = "ثمانية"
Case Is = 9 : letter1 = "تسعة"
End Select
Dim C2 As Double = Val(Mid(c, 11, 1))
Select Case C2
Case Is = 1 : letter2 = "عشر"
Case Is = 2 : letter2 = "عشرون"
Case Is = 3 : letter2 = "ثلاثون"
Case Is = 4 : letter2 = "اربعون"
Case Is = 5 : letter2 = "خمسون"
Case Is = 6 : letter2 = "ستون"
Case Is = 7 : letter2 = "سبعون"
Case Is = 8 : letter2 = "ثمانون"
Case Is = 9 : letter2 = "تسعون"
End Select
If letter1 <> "" And C2 > 1 Then letter2 = letter1 + " و" + letter2
If letter2 = "" Or letter2 Is Nothing Then
letter2 = letter1
End If
If C1 = 0 And C2 = 1 Then letter2 = letter2 + "ة"
If C1 = 1 And C2 = 1 Then letter2 = "احدى عشر"
If C1 = 2 And C2 = 1 Then letter2 = "اثنى عشر"
If C1 > 2 And C2 = 1 Then letter2 = letter1 + " " + letter2
Dim C3 As Double = Val(Mid(c, 10, 1))
Select Case C3
Case Is = 1 : letter3 = "مائة"
Case Is = 2 : letter3 = "مئتان"
Case Is > 2 : letter3 = Left(SFormatNumber(C3), Len(SFormatNumber(C3)) - 1) + "مائة"
End Select
If letter3 <> "" And letter2 <> "" Then letter3 = letter3 + " و" + letter2
If letter3 = "" Then letter3 = letter2
Dim C4 As Double = Val(Mid(c, 7, 3))
Select Case C4
Case Is = 1 : letter4 = "الف"
Case Is = 2 : letter4 = "الفان"
Case 3 To 10 : letter4 = SFormatNumber(C4) + " آلاف"
Case Is > 10 : letter4 = SFormatNumber(C4) + " الف"
End Select
If letter4 <> "" And letter3 <> "" Then letter4 = letter4 + " و" + letter3
If letter4 = "" Then letter4 = letter3
Dim C5 As Double = Val(Mid(c, 4, 3))
Select Case C5
Case Is = 1 : letter5 = "مليون"
Case Is = 2 : letter5 = "مليونان"
Case 3 To 10 : letter5 = SFormatNumber(C5) + " ملايين"
Case Is > 10 : letter5 = SFormatNumber(C5) + " مليون"
End Select
If letter5 <> "" And letter4 <> "" Then letter5 = letter5 + " و" + letter4
If letter5 = "" Then letter5 = letter4
Dim C6 As Double = Val(Mid(c, 1, 3))
Select Case C6
Case Is = 1 : letter6 = "مليار"
Case Is = 2 : letter6 = "ملياران"
Case Is > 2 : letter6 = SFormatNumber(C6) + " مليار"
End Select
If letter6 <> "" And letter5 <> "" Then letter6 = letter6 + " و" + letter5
If letter6 = "" Then letter6 = letter5
SFormatNumber = letter6
End Function
End Class
No comments:
Post a Comment