[oodisc] ÞÉÓÌÏ_ÐÒÏÐÉÓØÀ

Vlad Vasiliev vlad ÎÁ gas.by
þÔ íÁÊ 22 11:43:41 MSD 2003


÷. åÆÉÍÅÎËÏ ÐÉÛÅÔ:

>õ×ÁÖÁÅÍÙÅ ÇÏÓÐÏÄÁ!
>îÉËÔÏ ÎÅ ÍÏÖÅÔ ÐÒÅÚÅÎÔÏ×ÁÔØ ÍÁËÒÏÓ (ÎÁÄÓÔÒÏÊËÕ) ÄÌÑ ïïï "þÉÓÌÏ (ÓÕÍÍÁ)
>ÐÒÏÐÉÓØÀ"?
>âÕÄÕ ×ÅÓØÍÁ ÐÒÉÚÎÁÔÅÌÅÎ.
>  
>
üÔÏÔ ÍÁËÒÏÓ ÏÓÎÏ×ÁÎ ÎÁ ÆÕÎËÃÉÉ ÎÁÐÉÓÁÎÎÏÊ  íÉÈÁÉÌÏÍ çÕÓÅ×ÙÍ.
÷ÌÁÄ.
----------- õíåäèüâó àâõæû -----------
REM  *****  BASIC  *****
 
Sub propis
Dim dd As Double
Dim st As String
	oSelect=ThisComponent.CurrentSelection.getRangeAddress
	oSelectColumn=ThisComponent.CurrentSelection.Columns
	oSelectRow=ThisComponent.CurrentSelection.Rows
	oSelectSC=oSelect.StartColumn
	oSelectSR=oSelect.StartRow
    oCell1=ActiveSheet.getCellByposition(oSelectSC,oSelectSR) 
'dd = 21.2234
dd=oCell1.getValue
' 0 - rub
' 1 - y.e.
st = Digit2String(dd, 0)
CellPos(oSelectSC,oSelectSR).setString(st)
End Sub

Function Digit2String(digit As Double, p As Integer) As String

' Îâìôðõ ÿâòêõâï 18.06.01 mikle-2
Dim W1(20) As String
Dim W1a(20) As String
Dim W10(10) As String
Dim W100(10) As String
Dim W1000(10) As String

W1(0) = ""
W1(1) = "ðäêï"
W1(2) = "äþâ"
W1(3) = "æôê"
W1(4) = "àåæýôå"
W1(5) = "òóæû"
W1(6) = "ùåõæû"
W1(7) = "õåîû"
W1(8) = "þðõåîû"
W1(9) = "äåþóæû"
W1(10) = "äåõóæû"
W1(11) = "ðäêïâäçâæû"
W1(12) = "äþåïâäçâæû"
W1(13) = "æôêïâäçâæû"
W1(14) = "àåæýôïâäçâæû"
W1(15) = "òóæïâäçâæû"
W1(16) = "ùåõæïâäçâæû"
W1(17) = "õåîïâäçâæû"
W1(18) = "þðõåîïâäçâæû"
W1(19) = "äåþóæïâäçâæû"
W1a(0) = ""
W1a(1) = "ðäïâ"
W1a(2) = "äþå"
W1a(3) = "æôê"
W1a(4) = "àåæýôå"
W1a(5) = "òóæû"
W1a(6) = "ùåõæû"
W1a(7) = "õåîû"
W1a(8) = "þðõåîû"
W1a(9) = "äåþóæû"
W1a(10) = "äåõóæû"
W1a(11) = "ðäêïâäçâæû"
W1a(12) = "äþåïâäçâæû"
W1a(13) = "æôêïâäçâæû"
W1a(14) = "àåæýôïâäçâæû"
W1a(15) = "òóæïâäçâæû"
W1a(16) = "ùåõæïâäçâæû"
W1a(17) = "õåîïâäçâæû"
W1a(18) = "þðõåîïâäçâæû"
W1a(19) = "äåþóæïâäçâæû"
W10(0) = ""
W10(1) = "äåõóæû"
W10(2) = "äþâäçâæû"
W10(3) = "æôêäçâæû"
W10(4) = "õðôðì"
W10(5) = "òóæûäåõóæ"
W10(6) = "ùåõæûäåõóæ"
W10(7) = "õåîûäåõóæ"
W10(8) = "þðõåîûäåõóæ"
W10(9) = "äåþóïðõæð"
W100(0) = ""
W100(1) = "õæð"
W100(2) = "äþåõæê"
W100(3) = "æôêõæâ"
W100(4) = "àåæýôåõæâ"
W100(5) = "òóæûõðæ"
W100(6) = "ùåõæûõðæ"
W100(7) = "õåîûõðæ"
W100(8) = "þðõåîûõðæ"
W100(9) = "äåþóæûõðæ"

Result = ""

e = Int((digit - Int(digit)) * 100) ' decimal
digit_long = Int(digit)
a = Int(digit_long / 1000000) '32123456/1000000 = 32 -> 106
b = digit_long - (a * 1000000) '32123456-32000000 = 123456
c = Int(b / 1000) '123456/1000 = 123 -> 103
d = b - (c * 1000) '123456-123*1000 = 456 -> 1

Add = ""
For i = 2 To 0 Step -1
    m = Int(a / (10 ^ i))
    If i = 2 Then
        If m <> 0 Then
            R = W100(m) + " "
            Add = "îêííêðïðþ "
        End If
    End If
    If i = 1 Then
        If m <> 0 Then
            If a < 20 Then
                Result = Result + W1(a) + " îêííêðïðþ "
                GoTo con_0
            End If
            R = W10(m) + " "
            Add = "îêííêðïðþ "
        End If
    End If
    If i = 0 Then
        If m <> 0 Then
            If m >= 5 Then
                R = W1(m) + " "
                Add = "îêííêðïðþ "
            End If
            If m <= 4 Then
                R = W1(m) + " "
                Add = "îêííêðïâ "
            End If
            If m = 1 Then
                R = "ðäêï "
                Add = "îêííêðï "
            End If
        End If
        
    End If
    a = a - (m * (10 ^ i))
    Result = Result + R
    R = ""
Next i
Result = Result + Add
con_0:

Add = ""
For i = 2 To 0 Step -1
    m = Int(c / (10 ^ i))
    If i = 2 Then
        If m <> 0 Then
            R = W100(m) + " "
            Add = "æýõóà "
        End If
    End If
    If i = 1 Then
        If m <> 0 Then
            If c < 20 Then
                Result = Result + W1(c) + " æýõóà "
                GoTo con_1
            End If
            R = W10(m) + " "
            Add = "æýõóà "
        End If
    End If
    If i = 0 Then
        If m <> 0 Then
            If m >= 5 Then
                R = W1(m) + " "
                Add = "æýõóà "
            End If
            If m <= 4 Then
                R = W1(m) + " "
                Add = "æýõóàê "
            End If
            If m = 2 Then
                R = "äþå "
                Add = "æýõóàê "
            End If
            If m = 1 Then
                R = "ðäïâ "
                Add = "æýõóàâ "
            End If
        End If
    End If
    c = c - (m * (10 ^ i))
    Result = Result + R
    R = ""
Next i
Result = Result + Add
con_1:

Add = ""
For i = 2 To 0 Step -1
    m = Int(d / (10 ^ i))
    If i = 2 Then
        If m <> 0 Then
            R = W100(m) + " "
        End If
    End If
    If i = 1 Then
        If m <> 0 Then
            If d < 20 Then
                R = W1(d) + " "
                Result = Result + R
                GoTo con_2
            End If
            R = W10(m) + " "
        End If
    End If
    If i = 0 Then
        If m <> 0 Then
            If p = 0 Then
                R = W1(m) + " "
            Else
                R = W1a(m) + " "
            End If
        End If
    End If
    
    d = d - (m * (10 ^ i))
    Result = Result + R
    R = ""
Next i
con_2:


If p = 0 Then       ' rub
    Result = Result + "ôè÷. "
End If

For i = 1 To 0 Step -1
    m = Int(e / (10 ^ i))
    Result = Result + Chr$(m + Asc("0"))
    e = e - (m * (10 ^ i))
Next i

If p = 0 Then       ' rub
    Result = Result + " ìðò."
Else                ' y.e.
    Result = Result + "/100 è.å"
End If

Digit2String = Result

End Function

Function CellPos(lColumn As Long,lRow As Long)
	CellPos= ActiveSheet.getCellByPosition (lColumn,lRow)
End Function

Function ActiveSheet
 	ActiveSheet=StarDesktop.CurrentComponent.CurrentController.ActiveSheet
End Function


ðÏÄÒÏÂÎÁÑ ÉÎÆÏÒÍÁÃÉÑ Ï ÓÐÉÓËÅ ÒÁÓÓÙÌËÉ Oo-discuss