0% found this document useful (0 votes)
56 views7 pages

تحويل الارقام الى كتابةبدون عنوان

This function converts a number to its text representation in Arabic. It takes a number, main currency, and sub currency as inputs. Internally it uses arrays to store the text representations of numbers from 0-9 in the hundreds, tens, and ones places. It then extracts the portions of the input number and concatenates the corresponding text representations together to form the output text.

Uploaded by

moslamy90
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views7 pages

تحويل الارقام الى كتابةبدون عنوان

This function converts a number to its text representation in Arabic. It takes a number, main currency, and sub currency as inputs. Internally it uses arrays to store the text representations of numbers from 0-9 in the hundreds, tens, and ones places. It then extracts the portions of the input number and concatenates the corresponding text representations together to form the output text.

Uploaded by

moslamy90
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Function NumberToText(Number As Double, MainCurrency As String, SubCurrency As String)

Dim Array1(0 To 9) As String

Dim Array2(0 To 9) As String

Dim Array3(0 To 9) As String

Dim MyNumber As String

Dim GetNumber As String

Dim ReadNumber As String

Dim My100 As String

Dim My10 As String

Dim My1 As String

Dim My11 As String

Dim My12 As String

Dim GetText As String

Dim Billion As String

Dim Million As String

Dim Thousand As String

Dim Hundred As String

Dim Fraction As String

Dim MyAnd As String

Dim I As Integer

Dim ReMark As String

If Number > 999999999999.99 Then Exit Function

If Number < 0 Then


Number = Number * -1

" ‫ = "سالب‬ReMark

End If

If Number = 0 Then

"‫ = "صفر‬NumberToText

Exit Function

End If

"‫ = " و‬MyAnd

"" = Array1(0)

"‫ = "مائة‬Array1(1)

"‫ = "مائتان‬Array1(2)

"‫ = "ثالثمائة‬Array1(3)

"‫ = "أربعمائة‬Array1(4)

"‫ = "خمسمائة‬Array1(5)

"‫ = "ستمائة‬Array1(6)

"‫ = "سبعمائة‬Array1(7)

"‫ = "ثمانمائة‬Array1(8)

"‫ = "تسعمائة‬Array1(9)

"" = Array2(0)

"‫ = " عشر‬Array2(1)

"‫ = "عشرون‬Array2(2)

"‫ = "ثالثون‬Array2(3)
"‫ = "أربعون‬Array2(4)

"‫ = "خمسون‬Array2(5)

"‫ = "ستون‬Array2(6)

"‫ = "سبعون‬Array2(7)

"‫ = "ثمانون‬Array2(8)

"‫ = "تسعون‬Array2(9)

"" = Array3(0)

"‫ = "واحد‬Array3(1)

"‫ = "اثنان‬Array3(2)

"‫ = "ثالثة‬Array3(3)

"‫ = "أربعة‬Array3(4)

"‫ = "خمسة‬Array3(5)

"‫ = "ستة‬Array3(6)

"‫ = "سبعة‬Array3(7)

"‫ = "ثمانية‬Array3(8)

"‫ = "تسعة‬Array3(9)

GetNumber = Format(Number, "000000000000.00")

I=0

Do While I < 15

If I < 12 Then

MyNumber = Mid$(GetNumber, I + 1, 3)
Else

MyNumber = "0" + Mid$(GetNumber, I + 2, 2)

End If

If (Mid$(MyNumber, 1, 3)) > 0 Then

ReadNumber = Mid$(MyNumber, 1, 1)

My100 = Array1(ReadNumber)

ReadNumber = Mid$(MyNumber, 3, 1)

My1 = Array3(ReadNumber)

ReadNumber = Mid$(MyNumber, 2, 1)

My10 = Array2(ReadNumber)

"‫ = "إحدى عشرة‬If Mid$(MyNumber, 2, 2) = 11 Then My11

"‫ = "إثنى عشرة‬If Mid$(MyNumber, 2, 2) = 12 Then My12

"‫ = "عشرة‬If Mid$(MyNumber, 2, 2) = 10 Then My10

If ((Mid$(MyNumber, 1, 1)) > 0) And ((Mid$(MyNumber, 2, 2)) > 0) Then My100 = My100 +
MyAnd

If ((Mid$(MyNumber, 3, 1)) > 0) And ((Mid$(MyNumber, 2, 1)) > 1) Then My1 = My1 +
MyAnd

GetText = My100 + My1 + My10

If ((Mid$(MyNumber, 3, 1)) = 1) And ((Mid$(MyNumber, 2, 1)) = 1) Then


GetText = My100 + My11

If ((Mid$(MyNumber, 1, 1)) = 0) Then GetText = My11

End If

If ((Mid$(MyNumber, 3, 1)) = 2) And ((Mid$(MyNumber, 2, 1)) = 1) Then

GetText = My100 + My12

If ((Mid$(MyNumber, 1, 1)) = 0) Then GetText = My12

End If

If (I = 0) And (GetText <> "") Then

If ((Mid$(MyNumber, 1, 3)) > 10) Then

"‫ " مليار‬+ Billion = GetText

Else

"‫ " مليارات‬+ Billion = GetText

"‫ = " مليار‬If ((Mid$(MyNumber, 1, 3)) = 2) Then Billion

"‫ = " مليارن‬If ((Mid$(MyNumber, 1, 3)) = 2) Then Billion

End If

End If

If (I = 3) And (GetText <> "") Then

If ((Mid$(MyNumber, 1, 3)) > 10) Then

"‫ " مليون‬+ Million = GetText

Else

"‫ " ماليين‬+ Million = GetText


"‫ = " مليون‬If ((Mid$(MyNumber, 1, 3)) = 1) Then Million

"‫ = " مليونان‬If ((Mid$(MyNumber, 1, 3)) = 2) Then Million

End If

End If

If (I = 6) And (GetText <> "") Then

If ((Mid$(MyNumber, 1, 3)) > 10) Then

"‫ " ألف‬+ Thousand = GetText

Else

"‫ " أالف‬+ Thousand = GetText

"‫ = " ألف‬If ((Mid$(MyNumber, 3, 1)) = 1) Then Thousand

"‫ = " ألفان‬If ((Mid$(MyNumber, 3, 1)) = 2) Then Thousand

End If

End If

If (I = 9) And (GetText <> "") Then Hundred = GetText

If (I = 12) And (GetText <> "") Then Fraction = GetText

End If

I=I+3

Loop

If (Billion <> "") Then

If (Million <> "") Or (Thousand <> "") Or (Hundred <> "") Then Billion = Billion + MyAnd

End If
If (Million <> "") Then

If (Thousand <> "") Or (Hundred <> "") Then Million = Million + MyAnd

End If

If (Thousand <> "") Then

If (Hundred <> "") Then Thousand = Thousand + MyAnd

End If

If Fraction <> "" Then

If (Billion <> "") Or (Million <> "") Or (Thousand <> "") Or (Hundred <> "") Then

NumberToText = ReMark + Billion + Million + Thousand + Hundred + " " + MainCurrency +


MyAnd + Fraction + " " + SubCurrency

Else

NumberToText = ReMark + Fraction + " " + SubCurrency

End If

Else

NumberToText = ReMark + Billion + Million + Thousand + Hundred + " " + MainCurrency

End If

End Function

You might also like