Advertisement
bousaid

AR Number To Text

Mar 17th, 2023
2,306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.06 KB | None | 0 0
  1. Public Function MTL(x)
  2.     Ma = " دينار جزائري"
  3.     Mi = " سنتيم."
  4.     n = Int(x)
  5.     B = Val(Right(Format(x, "000000000000.00"), 2))
  6.     R = SHorof(n)
  7.     If R <> "" And B > 0 Then Result = R & Ma & " و " & B & Mi
  8.     If R <> "" And B = 0 Then Result = R & Ma
  9.     If R = "" And B <> 0 Then Result = B & Mi
  10.     MTL = Result
  11. End Function
  12. Private Function SHorof(x)
  13.     n = Int(x)
  14.     C = Format(n, "000000000000")
  15.     c1 = Val(Mid(C, 12, 1))
  16.     Select Case c1
  17.     Case Is = 1: Letter1 = "واحد"
  18.     Case Is = 2: Letter1 = "إثنان"
  19.     Case Is = 3: Letter1 = "ثلاثة"
  20.     Case Is = 4: Letter1 = "أربعة"
  21.     Case Is = 5: Letter1 = "خمسة"
  22.     Case Is = 6: Letter1 = "ستة"
  23.     Case Is = 7: Letter1 = "سبعة"
  24.     Case Is = 8: Letter1 = "ثمانية"
  25.     Case Is = 9: Letter1 = "تسعة"
  26. End Select
  27.     c2 = Val(Mid(C, 11, 1))
  28.     Select Case c2
  29.     Case Is = 1: Letter2 = "عشرة"
  30.     Case Is = 2: Letter2 = "عشرون"
  31.     Case Is = 3: Letter2 = "ثلاثون"
  32.     Case Is = 4: Letter2 = "اربعون"
  33.     Case Is = 5: Letter2 = "خمسون"
  34.     Case Is = 6: Letter2 = "ستون"
  35.     Case Is = 7: Letter2 = "سبعون"
  36.     Case Is = 8: Letter2 = "ثمانون"
  37.     Case Is = 9: Letter2 = "تسعون"
  38.     End Select
  39.    
  40.     If Letter1 <> "" And c2 > 1 Then Letter2 = Letter1 + " و" + Letter2
  41.     If Letter2 = "" Then Letter2 = Letter1
  42.     If c1 = 0 And c2 = 1 Then Letter2 = Letter2 + "ة"
  43.     If c1 = 1 And c2 = 1 Then Letter2 = "إحدى عشرة"
  44.     If c1 = 2 And c2 = 1 Then Letter2 = "إثنى عشرة"
  45.     If c1 > 2 And c2 = 1 Then Letter2 = Letter1 + " " + Letter2
  46.     c3 = Val(Mid(C, 10, 1))
  47.     Select Case c3
  48.     Case Is = 1: Letter3 = "مائة"
  49.     Case Is = 2: Letter3 = "مئتان"
  50.     Case Is > 2: Letter3 = Left(SHorof(c3), Len(SHorof(c3)) - 1) + "مائة"
  51.     End Select
  52.     If Letter3 <> "" And Letter2 <> "" Then Letter3 = Letter3 + " و" + Letter2
  53.     If Letter3 = "" Then Letter3 = Letter2
  54.    
  55.    C4 = Val(Mid(C, 7, 3))
  56.    Select Case C4
  57.    Case Is = 1: Letter4 = "ألف"
  58.    Case Is = 2: Letter4 = "ألفان"
  59.    Case 3 To 10: Letter4 = SHorof(C4) + " آلاف"
  60.    Case Is > 10: Letter4 = SHorof(C4) + " ألف"
  61.    End Select
  62.    If Letter4 <> "" And Letter3 <> "" Then Letter4 = Letter4 + " و" + Letter3
  63.    If Letter4 = "" Then Letter4 = Letter3
  64.    C5 = Val(Mid(C, 4, 3))
  65.    Select Case C5
  66.    Case Is = 1: Letter5 = "مليون"
  67.    Case Is = 2: Letter5 = "مليونان"
  68.    Case 3 To 10: Letter5 = SHorof(C5) + " ملايين"
  69.    Case Is > 10: Letter5 = SHorof(C5) + " مليون"
  70.    End Select
  71.    If Letter5 <> "" And Letter4 <> "" Then Letter5 = Letter5 + " و" + Letter4
  72.    If Letter5 = "" Then Letter5 = Letter4
  73.    
  74.    C6 = Val(Mid(C, 1, 3))
  75.    Select Case C6
  76.    Case Is = 1: Letter6 = "مليار"
  77.    Case Is = 2: Letter6 = "ملياران"
  78.    Case Is > 2: Letter6 = SHorof(C6) + " مليار"
  79.    End Select
  80.    If Letter6 <> "" And Letter5 <> "" Then Letter6 = Letter6 + " و" + Letter5
  81.    If Letter6 = "" Then Letter6 = Letter5
  82.    SHorof = Letter6
  83.    
  84. End Function
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement