Advertisement
Varanthan

Untitled

Mar 13th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. Function Słownie(x As Variant) As String 'dla liczb od -99 999.99 do 99 999.99
  2. If x < 0 Then w = w & "minus "
  3. x = Format(Abs(x), "000 000 000.00"): m = Left(x, 3): t = Mid(x, 5, 3): j = Mid(x, 9, 3): g = "0" & Right(x, 2)
  4. Select Case m
  5. Case 0
  6. Case 1
  7. w = "jeden milion "
  8. Case Else
  9. w = w & trzy(m)
  10. If Mid(m, 2, 1) <> 1 And (Right(m, 1) = 2 Or Right(m, 1) = 3 Or Right(m, 1) = 4) Then w = w & "miliony " Else w = w & "milionów "
  11. End Select
  12. Select Case t
  13. Case 0
  14. Case 1
  15. w = w & "jeden tysiąc "
  16. Case Else
  17. w = w & trzy(t)
  18. If Mid(t, 2, 1) <> 1 And (Right(t, 1) = 2 Or Right(t, 1) = 3 Or Right(t, 1) = 4) Then w = w & "tysiące " Else w = w & "tysięcy "
  19. End Select
  20. Select Case j
  21. Case 0
  22. If m = 0 And t = 0 Then w = w & "zero" Else w = w & " "
  23. Case 1
  24. If m = 0 And t = 0 Then w = w & "jeden" Else w = w & "jeden "
  25. Case Else
  26. w = w & trzy(j)
  27. If Mid(j, 2, 1) <> 1 And (Right(j, 1) = 2 Or Right(j, 1) = 3 Or Right(j, 1) = 4) Then w = w & " " Else w = w & " "
  28. End Select
  29. Słownie = w
  30. End Function
  31. Function trzy(x As Variant) As String
  32. x3 = Val(Left(x, 1)): x2 = Val(Mid(x, 2, 1)): x1 = Val(Right(x, 1))
  33. If x3 = 9 Then w = w & "dziewięćset "
  34. If x3 = 8 Then w = w & "osiemset "
  35. If x3 = 7 Then w = w & "siedemset "
  36. If x3 = 6 Then w = w & "sześćset "
  37. If x3 = 5 Then w = w & "pięćset "
  38. If x3 = 4 Then w = w & "czterysta "
  39. If x3 = 3 Then w = w & "trzysta "
  40. If x3 = 2 Then w = w & "dwieście "
  41. If x3 = 1 Then w = w & "sto "
  42. If x2 = 9 Then w = w & "dziewięćdziesiąt "
  43. If x2 = 8 Then w = w & "osiemdziesiąt "
  44. If x2 = 7 Then w = w & "siedemdziesiąt "
  45. If x2 = 6 Then w = w & "sześćdziesiąt "
  46. If x2 = 5 Then w = w & "pięćdziesiąt "
  47. If x2 = 4 Then w = w & "czterdzieści "
  48. If x2 = 3 Then w = w & "trzydzieści "
  49. If x2 = 2 Then w = w & "dwadzieścia "
  50. If x2 = 1 Then
  51. If x1 = 9 Then w = w & "dziewiętnaście "
  52. If x1 = 8 Then w = w & "osiemnaście "
  53. If x1 = 7 Then w = w & "siedemnaście "
  54. If x1 = 6 Then w = w & "szesnaście "
  55. If x1 = 5 Then w = w & "piętnaście "
  56. If x1 = 4 Then w = w & "czternaście "
  57. If x1 = 3 Then w = w & "trzynaście "
  58. If x1 = 2 Then w = w & "dwanaście "
  59. If x1 = 1 Then w = w & "jedenaście "
  60. If x1 = 0 Then w = w & "dziesięć "
  61. End If
  62. If x2 <> 1 Then
  63. If x1 = 9 Then w = w & "dziewięć "
  64. If x1 = 8 Then w = w & "osiem "
  65. If x1 = 7 Then w = w & "siedem "
  66. If x1 = 6 Then w = w & "sześć "
  67. If x1 = 5 Then w = w & "pięć "
  68. If x1 = 4 Then w = w & "cztery "
  69. If x1 = 3 Then w = w & "trzy "
  70. If x1 = 2 Then w = w & "dwa "
  71. If x1 = 1 Then w = w & "jeden "
  72. End If
  73. trzy = w
  74. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement