TGViewer
UstozMahmud UstozMahmud @ustozmahmudd · 1.81K subscribers
Post #160 2K
69-kun videosida ishlatilgan kodlar

Function NumberToWordUZ(ByVal Num As Double) As String

Dim integerPart As Double
Dim decimalPart As Integer
Dim result As String

' Manfiy sonlar
If Num < 0 Then
NumberToWordUZ = "minus " & NumberToWordUZ(Abs(Num))
Exit Function
End If

integerPart = Int(Num)
decimalPart = Round((Num - integerPart) * 100, 0)

result = NumberGroupToWord(integerPart) & " so‘m"

If decimalPart > 0 Then
result = result & " " & NumberGroupToWord(decimalPart) & " tiyin"
End If

NumberToWordUZ = Application.WorksheetFunction.Trim(result)

End Function


Private Function NumberGroupToWord(ByVal Num As Double) As String

Dim ones As Variant
ones = Array("", "bir", "ikki", "uch", "to‘rt", "besh", "olti", "yetti", "sakkiz", "to‘qqiz")

Dim tens As Variant
tens = Array("", "o‘n", "yigirma", "o‘ttiz", "qirq", "ellik", "oltmish", "yetmish", "sakson", "to‘qson")

Dim thousands As Variant
thousands = Array("", "ming", "million", "milliard", "trillion")

If Num = 0 Then
NumberGroupToWord = "nol"
Exit Function
End If

Dim result As String
Dim i As Integer
i = 0

Do While Num > 0
Dim part As Integer
part = Num Mod 1000

If part <> 0 Then
result = ConvertHundredsUZ(part) & " " & thousands(i) & " " & result
End If

Num = Int(Num / 1000)
i = i + 1
Loop

NumberGroupToWord = Application.WorksheetFunction.Trim(result)

End Function


Private Function ConvertHundredsUZ(ByVal Num As Integer) As String

Dim ones As Variant
ones = Array("", "bir", "ikki", "uch", "to‘rt", "besh", "olti", "yetti", "sakkiz", "to‘qqiz")

Dim tens As Variant
tens = Array("", "o‘n", "yigirma", "o‘ttiz", "qirq", "ellik", "oltmish", "yetmish", "sakson", "to‘qson")

Dim result As String

If Num >= 100 Then
result = ones(Int(Num / 100)) & " yuz "
Num = Num Mod 100
End If

If Num >= 10 Then
result = result & tens(Int(Num / 10)) & " "
Num = Num Mod 10
End If

If Num > 0 Then
result = result & ones(Num)
End If

ConvertHundredsUZ = result

End Function
  • ❤ 6
  • 🔥 4
  • ⚡ 2
More from @ustozmahmudd
  1. Sep 28, 2026📊 Excel 98-kun Excel bo‘yicha 98-kunlik amaliy sayohatimiz davom etmoqda! 🚀 Bugungi dars…
  2. Sep 24, 2026📊 Excel 97-kun Excel bo‘yicha amaliy darslarimiz davom etmoqda! 🚀 Bugungi darsda real is…
  3. Sep 22, 2026📊 Excel 96-kun Excel bo‘yicha amaliy darslarimiz davom etmoqda! 🚀 Bugungi darsda real is…
  4. Sep 19, 2026📊 Excel 95-kun Excel bo‘yicha 95-kunlik amaliy o‘rganish yo‘limiz davom etmoqda! 🚀 Bugun…
  5. Sep 18, 2026📊 Excel 94-kun Bugungi darsda Excel’ning yana bir foydali imkoniyatini amaliy misol orqal…
  6. Sep 17, 2026📊 Excel 93-kun Bugungi darsda Excel bilan ishlashni yanada osonlashtiradigan foydali usul…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →