Re: EXCEL-format bunky

From: Sokol (sokol01@seznam.cz)
Date: 02. 10. 2003, 19:46 CEST


Zdravim Mike,

tady to mas
neni to ode mne (dik Kamile), jen jsem to opravil a upravil
umi to vypsat i halere
volas to =CisloNaText(X) kde X je bunka s cislem

------------- zacatek

Option Explicit

Function CisloNaText(cislo)
    Dim text As String
    Dim desetiny As String
    Dim des As Byte
    
    
        '________kontroly ________
    
    If cislo > 1000000 Then
        MsgBox "cislo je vetsi jak Milion"
        Exit Function    'do milionu
    End If
    des = Round(cislo - Int(cislo), 1) * 100 'halere
    desetiny = " a " & des & " hal."
    If des = 0 Then
        desetiny = "" 'pokud jsou halere 0 tak nic neprida
    End If
    cislo = Int(cislo)      'Zaokrouhli cislo
        '_________________________
    
    If cislo >= 1000 And cislo < 5000 Then
        text = retezec(Int(cislo / 1000) * 1000)
        cislo = cislo - Int(cislo / 1000) * 1000
    ElseIf cislo >= 5000 Then
        text = TriCisla(Left(Trim(Str(cislo)), Len(Trim(Str(cislo))) - 3)) & "tisíc"
        cislo = cislo - Val(Left(Trim(Str(cislo)), Len(Trim(Str(cislo))) - 3)) * 1000
    End If
    text = text & TriCisla(cislo)
    CisloNaText = text & desetiny
End Function

Private Function TriCisla(cislo)
    Dim text As String
            
            'Pro čísla od 100 do 999
    If cislo > 99 Then
        text = retezec(Int(cislo / 100) * 100)
        cislo = cislo - Int(cislo / 100) * 100
    End If
        'Pro čísla do 100
    If cislo > 19 Then
        text = text & retezec(Int(cislo / 10) * 10) & retezec(cislo - Int(cislo / 10) * 10)
    Else
        text = text & retezec(cislo)
    End If
    TriCisla = text
End Function

Private Function retezec(cislo)
    Dim text As String
    If cislo = 1 Then
            text = "jedna"
    ElseIf cislo = 2 Then
            text = "dvě"
    ElseIf cislo = 3 Then
            text = "tři"
    ElseIf cislo = 4 Then
            text = "čtyři"
    ElseIf cislo = 5 Then
            text = "pět"
    ElseIf cislo = 6 Then
            text = "šest"
    ElseIf cislo = 7 Then
            text = "sedm"
    ElseIf cislo = 8 Then
            text = "osm"
    ElseIf cislo = 9 Then
            text = "devět"
    ElseIf cislo = 10 Then
            text = "deset"
    ElseIf cislo = 11 Then
            text = "jedenáct"
    ElseIf cislo >= 12 And cislo <= 14 Then
            text = retezec(Val(Right(cislo, 1))) & "náct"
    ElseIf cislo = 15 Then
            text = "patnáct"
    ElseIf cislo >= 16 And cislo <= 18 Then
            text = retezec(Val(Right(cislo, 1))) & "náct"
    ElseIf cislo = 19 Then
            text = "devatenáct"
    ElseIf cislo = 20 Then
            text = "dvacet"
    ElseIf cislo >= 30 And cislo <= 40 Then
            text = retezec(Val(Left(cislo, 1))) & "cet"
    ElseIf cislo = 50 Then
            text = "padesát"
    ElseIf cislo = 60 Then
            text = "šedesát"
    ElseIf cislo >= 70 And cislo <= 80 Then
            text = retezec(Val(Left(cislo, 1))) & "desát"
    ElseIf cislo = 90 Then
            text = "devadesát"
    ElseIf cislo = 100 Then
            text = "sto"
    ElseIf cislo >= 200 And cislo < 300 Then
        text = retezec(Val(Left(cislo, 1))) & "stě"
    ElseIf cislo >= 300 And cislo <= 400 Then
        text = retezec(Val(Left(cislo, 1))) & "sta"
    ElseIf cislo >= 500 And cislo <= 900 Then
        text = retezec(Val(Left(cislo, 1))) & "set"
    ElseIf cislo = 1000 Then
            text = "tisíc"
    ElseIf cislo = 2000 Then
            text = "dvatisíce"
    ElseIf cislo >= 3000 And cislo <= 4000 Then
        text = retezec(Val(Left(cislo, 1))) & "tisíce"
    End If
    
    retezec = text
End Function

------------- konec





-- 
Zdravi
 Sokol                        


E-mail: sokol01@atlas.cz
ICQ #65208171

'We are all immortal
    until we die'
 Flitzanu the Silly



This archive was generated by hypermail 2.1.3 : 02. 10. 2003, 19:48 CEST