Tema: Re: CROSS: skaiciu vertimas i zodzius Excelyje
Autorius: Linas Petkevičius
Data: 2011-01-14 07:54:24
Public Function Suma_Lt(ByVal Suma) As String
Dim minus As String

If IsNull(Suma) Or Suma = 0 Then
Suma_Lt = ""
Exit Function
End If

If Suma < 0 Then
Suma = Abs(Suma)
minus = "minus "
Else
minus = ""
End If

Dim ct$, X, Mase, MasesSuma, Liko, i, Liet$, Linksnis, Pirma$, Kitos$


Static Pinigai$(3, 3)
    Pinigai$(1, 1) = "litas"
    Pinigai$(1, 2) = "litai"
    Pinigai$(1, 3) = "litø"
    Pinigai$(2, 1) = "tûkstantis"
    Pinigai$(2, 2) = "tûkstanèiai"
    Pinigai$(2, 3) = "tûkstanèiø"
    Pinigai$(3, 1) = "milijonas"
    Pinigai$(3, 2) = "milijonai"
    Pinigai$(3, 3) = "milijonø"
Static M(3)
    M(1) = 1
    M(2) = 1000
    M(3) = 1000000

Const Max_sk = 36     'Masyvo elementø skaièius
Static SkaiciaiN(36)
    SkaiciaiN(1) = 1
    SkaiciaiN(2) = 2
    SkaiciaiN(3) = 3
    SkaiciaiN(4) = 4
    SkaiciaiN(5) = 5
    SkaiciaiN(6) = 6
    SkaiciaiN(7) = 7
    SkaiciaiN(8) = 8
    SkaiciaiN(9) = 9
    SkaiciaiN(10) = 10
    SkaiciaiN(11) = 11
    SkaiciaiN(12) = 12
    SkaiciaiN(13) = 13
    SkaiciaiN(14) = 14
    SkaiciaiN(15) = 15
    SkaiciaiN(16) = 16
    SkaiciaiN(17) = 17
    SkaiciaiN(18) = 18
    SkaiciaiN(19) = 19
    SkaiciaiN(20) = 20
    SkaiciaiN(21) = 30
    SkaiciaiN(22) = 40
    SkaiciaiN(23) = 50
    SkaiciaiN(24) = 60
    SkaiciaiN(25) = 70
    SkaiciaiN(26) = 80
    SkaiciaiN(27) = 90
    SkaiciaiN(28) = 100
    SkaiciaiN(29) = 200
    SkaiciaiN(30) = 300
    SkaiciaiN(31) = 400
    SkaiciaiN(32) = 500
    SkaiciaiN(33) = 600
    SkaiciaiN(34) = 700
    SkaiciaiN(35) = 800
    SkaiciaiN(36) = 900

Static SkaiciaiS$(36)
    SkaiciaiS$(1) = "vienas"
    SkaiciaiS$(2) = "du"
    SkaiciaiS$(3) = "trys"
    SkaiciaiS$(4) = "keturi"
    SkaiciaiS$(5) = "penki"
    SkaiciaiS$(6) = "ðeði"
    SkaiciaiS$(7) = "septyni"
    SkaiciaiS$(8) = "aðtuoni"
    SkaiciaiS$(9) = "devyni"
    SkaiciaiS$(10) = "deðimt"
    SkaiciaiS$(11) = "vienuolika"
    SkaiciaiS$(12) = "dvylika"
    SkaiciaiS$(13) = "trylika"
    SkaiciaiS$(14) = "keturiolika"
    SkaiciaiS$(15) = "penkiolika"
    SkaiciaiS$(16) = "ðeðiolika"
    SkaiciaiS$(17) = "septyniolika"
    SkaiciaiS$(18) = "aðtuoniolika"
    SkaiciaiS$(19) = "devyniolika"
    SkaiciaiS$(20) = "dvideðimt"
    SkaiciaiS$(21) = "trisdeðimt"
    SkaiciaiS$(22) = "keturiasdeðimt"
    SkaiciaiS$(23) = "penkiasdeðimt"
    SkaiciaiS$(24) = "ðeðiasdeðimt"
    SkaiciaiS$(25) = "septyniasdeðimt"
    SkaiciaiS$(26) = "aðtuoniasdeðimt"
    SkaiciaiS$(27) = "devyniasdeðimt"
    SkaiciaiS$(28) = "vienas ðimtas"
    SkaiciaiS$(29) = "du ðimtai"
    SkaiciaiS$(30) = "trys ðimtai"
    SkaiciaiS$(31) = "keturi ðimtai"
    SkaiciaiS$(32) = "penki ðimtai"
    SkaiciaiS$(33) = "ðeði ðimtai"
    SkaiciaiS$(34) = "septyni ðimtai"
    SkaiciaiS$(35) = "aðtuoni ðimtai"
    SkaiciaiS$(36) = "devyni ðimtai"

Static SkaiciaiL(36)
    SkaiciaiL(1) = 1
    SkaiciaiL(2) = 2
    SkaiciaiL(3) = 2
    SkaiciaiL(4) = 2
    SkaiciaiL(5) = 2
    SkaiciaiL(6) = 2
    SkaiciaiL(7) = 2
    SkaiciaiL(8) = 2
    SkaiciaiL(9) = 2
    SkaiciaiL(10) = 3
    SkaiciaiL(11) = 3
    SkaiciaiL(12) = 3
    SkaiciaiL(13) = 3
    SkaiciaiL(14) = 3
    SkaiciaiL(15) = 3
    SkaiciaiL(16) = 3
    SkaiciaiL(17) = 3
    SkaiciaiL(18) = 3
    SkaiciaiL(19) = 3
    SkaiciaiL(20) = 3
    SkaiciaiL(21) = 3
    SkaiciaiL(22) = 3
    SkaiciaiL(23) = 3
    SkaiciaiL(24) = 3
    SkaiciaiL(25) = 3
    SkaiciaiL(26) = 3
    SkaiciaiL(27) = 3
    SkaiciaiL(28) = 3
    SkaiciaiL(29) = 3
    SkaiciaiL(30) = 3
    SkaiciaiL(31) = 3
    SkaiciaiL(32) = 3
    SkaiciaiL(33) = 3
    SkaiciaiL(34) = 3
    SkaiciaiL(35) = 3
    SkaiciaiL(36) = 3

    'Tuojau pat iðskirsime centus
    ct$ = Right(Format(Suma, "0.00"), 2)
    For X = 3 To 1 Step -1
    Mase = M(X)                     ' kà skaièiuosime: milijonus, 
tûkstanèius, litus
    MasesSuma = Int(Suma / Mase)    ' ðtai tiek tø milijunø
    Liko = Suma - MasesSuma * Mase  ' tiek dar liks sekanèiam kartui
    Suma = MasesSuma
    If Suma > 0 Then                ' ar yra nors vienas milijonas?
        For i = Max_sk To 1 Step -1                             ' teks 
pereiti per visà masyvà
            If Suma >= SkaiciaiN(i) Then                    ' gal jau tas 
skaièius
                Liet$ = Liet$ + SkaiciaiS$(i) + " "     ' prijungsim jo 
pavadinimà
                Linksnis = SkaiciaiL(i)                 ' ásiminsim jo 
linksná
                Suma = Suma - SkaiciaiN(i)              ' ir iðmesim já ið 
galvos
            End If
        Next i
        Liet$ = Liet$ + Pinigai$(X, Linksnis) + " "     'nepamirðkim pridëti 
milijono!
    End If
    Suma = Liko     'paskaièiuosim tai, kà palikome sekanèiam kartui
    Linksnis = 3    'dël visa ko galvosim apie ðá linksná
    Next X
    If MasesSuma = 0 Then Liet$ = Liet$ + "litø"    ' jei buvo gryni 
milijonai arba tûkstanèiai,
                            ' reikia pridëti þodelá LITAS
    'Cento tikslumu!
    Liet$ = Trim(Liet$) & " " & ct$ & " ct"

    'Pirma raidë - didþioji
    Pirma$ = UCase$(Left$(Liet$, 1))
    Kitos$ = Right$(Liet$, (Len(Liet$) - 1))
    Suma_Lt = minus + Pirma$ + Kitos$

    End Function

"10 milijonu"  wrote in message news:igntcm$bes$1@trimpas.omnitel.net...

Sveiki

Gal kas turite ir galite pasidalinti formulyte Excelyje,  kuri skaiciais
irasyta suma paverstu i suma zodziais

Aciu
10Milijonu