Private Sub Text7_LostFocus()
    Dim n(12) As Byte
    Dim k As String, s As Byte, i As Byte
    On Error GoTo ErrorInput
 
    k = Text7.Text
    If InStr(k, "=") = Len(k) Then
        i = Len(k) - 1
        s = i
        If s <= 12 Then
            If Left(k, 1) > 0 Then GoTo 10
        End If
    End If
    If InStr(k, "-") = Len(k) - 2 Then
        i = Len(k) - 3
        s = i
        If s <= 12 Then
            If Left(k, 1) > 0 Then GoTo 10
            If Left(k, s) = 0 Then GoTo 10
        End If
    End If
    GoTo ErrorInput
 
10  For i = 1 To s
    n(i) = Mid(k, s - i + 1, 1)
    Next i
    i = s
 
    If i = 1 Then GoTo 50
    If i = 2 Then GoTo 60
    If i = 3 Then GoTo 70
    If i = 4 Then GoTo 80
    If i = 5 Then GoTo 60
    If i = 6 Then GoTo 70
    If i = 7 Then GoTo 50
    If i = 8 Then GoTo 60
    If i = 9 Then GoTo 70
    If i = 10 Then GoTo 50
    If i = 11 Then GoTo 60
    If i = 12 Then GoTo 70
    If i > 12 Then GoTo ErrorInput
 

20  If i = 0 Then Exit Sub
    If i = 1 Then GoTo 100
    If i = 2 Then GoTo 200
    If i = 3 Then GoTo 300
    If i = 4 Then GoTo 400
    If i = 5 Then GoTo 200
    If i = 6 Then GoTo 300
    If i = 7 Then GoTo 100
    If i = 8 Then GoTo 200
    If i = 9 Then GoTo 300
    If i = 10 Then GoTo 100
    If i = 11 Then GoTo 200
 
300 If Mid(k, s - i + 1, 1) = 1 Then Text4.Text = Text4.Text + " сто"
    If Mid(k, s - i + 1, 1) = 2 Then Text4.Text = Text4.Text + " двести"
    If Mid(k, s - i + 1, 1) = 3 Then Text4.Text = Text4.Text + " триста"
    If Mid(k, s - i + 1, 1) = 4 Then Text4.Text = Text4.Text + " четыреста"
    If Mid(k, s - i + 1, 1) = 5 Then Text4.Text = Text4.Text + " пятьсот"
    If Mid(k, s - i + 1, 1) = 6 Then Text4.Text = Text4.Text + " шестьсот"
    If Mid(k, s - i + 1, 1) = 7 Then Text4.Text = Text4.Text + " семьсот"
    If Mid(k, s - i + 1, 1) = 8 Then Text4.Text = Text4.Text + " восемьсот"
    If Mid(k, s - i + 1, 1) = 9 Then Text4.Text = Text4.Text + " девятьсот"
 
    i = i - 1
    GoTo 20
 
 
200 If Mid(k, s - i + 1, 1) = 1 Then GoTo 500
    If Mid(k, s - i + 1, 1) = 2 Then Text4.Text = Text4.Text + " двадцать"
    If Mid(k, s - i + 1, 1) = 3 Then Text4.Text = Text4.Text + " тридцать"
    If Mid(k, s - i + 1, 1) = 4 Then Text4.Text = Text4.Text + " сорок"
    If Mid(k, s - i + 1, 1) = 5 Then Text4.Text = Text4.Text + " пятьдесят"
    If Mid(k, s - i + 1, 1) = 6 Then Text4.Text = Text4.Text + " шестьдесят"
    If Mid(k, s - i + 1, 1) = 7 Then Text4.Text = Text4.Text + " семьдесят"
    If Mid(k, s - i + 1, 1) = 8 Then Text4.Text = Text4.Text + " восемьдесят"
    If Mid(k, s - i + 1, 1) = 9 Then Text4.Text = Text4.Text + " девяносто"
    i = i - 1
    GoTo 20
 
100 If Mid(k, s - i + 1, 1) = 1 Then Text4.Text = Text4.Text + " один"
    If Mid(k, s - i + 1, 1) = 2 Then Text4.Text = Text4.Text + " два"
    If Mid(k, s - i + 1, 1) = 3 Then Text4.Text = Text4.Text + " три"
    If Mid(k, s - i + 1, 1) = 4 Then Text4.Text = Text4.Text + " четыре"
    If Mid(k, s - i + 1, 1) = 5 Then Text4.Text = Text4.Text + " пять"
    If Mid(k, s - i + 1, 1) = 6 Then Text4.Text = Text4.Text + " шесть"
    If Mid(k, s - i + 1, 1) = 7 Then Text4.Text = Text4.Text + " семь"
    If Mid(k, s - i + 1, 1) = 8 Then Text4.Text = Text4.Text + " восемь"
    If Mid(k, s - i + 1, 1) = 9 Then Text4.Text = Text4.Text + " девять"
    If i = 1 Then GoTo 701
    If i = 7 Then GoTo 702
    If i = 10 Then GoTo 703
 
 
 
 
400 If Mid(k, s - i + 1, 1) = 1 Then Text4.Text = Text4.Text + " одна"
    If Mid(k, s - i + 1, 1) = 2 Then Text4.Text = Text4.Text + " две"
    If Mid(k, s - i + 1, 1) = 3 Then Text4.Text = Text4.Text + " три"
    If Mid(k, s - i + 1, 1) = 4 Then Text4.Text = Text4.Text + " четыре"
    If Mid(k, s - i + 1, 1) = 5 Then Text4.Text = Text4.Text + " пять"
    If Mid(k, s - i + 1, 1) = 6 Then Text4.Text = Text4.Text + " шесть"
    If Mid(k, s - i + 1, 1) = 7 Then Text4.Text = Text4.Text + " семь"
    If Mid(k, s - i + 1, 1) = 8 Then Text4.Text = Text4.Text + " восемь"
    If Mid(k, s - i + 1, 1) = 9 Then Text4.Text = Text4.Text + " девять"
    If i = 4 Then GoTo 704
    GoTo 20

500 If Mid(k, s - i + 1, 2) = 11 Then Text4.Text = Text4.Text + " одиннадцать"
    If Mid(k, s - i + 1, 2) = 12 Then Text4.Text = Text4.Text + " двенадцать"
    If Mid(k, s - i + 1, 2) = 13 Then Text4.Text = Text4.Text + " тринадцать"
    If Mid(k, s - i + 1, 2) = 14 Then Text4.Text = Text4.Text + " четырнадцать"
    If Mid(k, s - i + 1, 2) = 15 Then Text4.Text = Text4.Text + " пятнадцать"
    If Mid(k, s - i + 1, 2) = 16 Then Text4.Text = Text4.Text + " шестнадцать"
    If Mid(k, s - i + 1, 2) = 17 Then Text4.Text = Text4.Text + " семнадцать"
    If Mid(k, s - i + 1, 2) = 18 Then Text4.Text = Text4.Text + " восемнадцать"
    If Mid(k, s - i + 1, 2) = 19 Then Text4.Text = Text4.Text + " девятнадцать"
    If Mid(k, s - i + 1, 2) = 10 Then Text4.Text = Text4.Text + " десять"
    If i = 5 Then Text4.Text = Text4.Text + " тысяч"
    If i = 8 Then Text4.Text = Text4.Text + " миллионов"
    If i = 11 Then Text4.Text = Text4.Text + " миллиардов"
    If i = 2 Then
        Text4.Text = Text4.Text + " рублей"
        If InStr(k, "-") > 0 Then GoTo 600
    End If
    i = i - 2
    GoTo 20
 
 
70  If Mid(k, s - i + 1, 1) = 1 Then Text4.Text = Text4.Text + " Сто"
    If Mid(k, s - i + 1, 1) = 2 Then Text4.Text = Text4.Text + " Двести"
    If Mid(k, s - i + 1, 1) = 3 Then Text4.Text = Text4.Text + " Триста"
    If Mid(k, s - i + 1, 1) = 4 Then Text4.Text = Text4.Text + " Четыреста"
    If Mid(k, s - i + 1, 1) = 5 Then Text4.Text = Text4.Text + " Пятьсот"
    If Mid(k, s - i + 1, 1) = 6 Then Text4.Text = Text4.Text + " Шестьсот"
    If Mid(k, s - i + 1, 1) = 7 Then Text4.Text = Text4.Text + " Семьсот"
    If Mid(k, s - i + 1, 1) = 8 Then Text4.Text = Text4.Text + " Восемьсот"
    If Mid(k, s - i + 1, 1) = 9 Then Text4.Text = Text4.Text + " Девятьсот"
    i = i - 1
    GoTo 20
 
 
60  If Mid(k, s - i + 1, 1) = 1 Then GoTo 90
    If Mid(k, s - i + 1, 1) = 2 Then Text4.Text = Text4.Text + " Двадцать"
    If Mid(k, s - i + 1, 1) = 3 Then Text4.Text = Text4.Text + " Тридцать"
    If Mid(k, s - i + 1, 1) = 4 Then Text4.Text = Text4.Text + " Сорок"
    If Mid(k, s - i + 1, 1) = 5 Then Text4.Text = Text4.Text + " Пятьдесят"
    If Mid(k, s - i + 1, 1) = 6 Then Text4.Text = Text4.Text + " Шестьдесят"
    If Mid(k, s - i + 1, 1) = 7 Then Text4.Text = Text4.Text + " Семьдесят"
    If Mid(k, s - i + 1, 1) = 8 Then Text4.Text = Text4.Text + " Восемьдесят"
    If Mid(k, s - i + 1, 1) = 9 Then Text4.Text = Text4.Text + " Девяносто"
    i = i - 1
    GoTo 20
 
50  If Mid(k, s - i + 1, 1) = 1 Then Text4.Text = Text4.Text + " Один"
    If Mid(k, s - i + 1, 1) = 2 Then Text4.Text = Text4.Text + " Два"
    If Mid(k, s - i + 1, 1) = 3 Then Text4.Text = Text4.Text + " Три"
    If Mid(k, s - i + 1, 1) = 4 Then Text4.Text = Text4.Text + " Четыре"
    If Mid(k, s - i + 1, 1) = 5 Then Text4.Text = Text4.Text + " Пять"
    If Mid(k, s - i + 1, 1) = 6 Then Text4.Text = Text4.Text + " Шесть"
    If Mid(k, s - i + 1, 1) = 7 Then Text4.Text = Text4.Text + " Семь"
    If Mid(k, s - i + 1, 1) = 8 Then Text4.Text = Text4.Text + " Восемь"
    If Mid(k, s - i + 1, 1) = 9 Then Text4.Text = Text4.Text + " Девять"
    If i = 1 Then GoTo 701
    If i = 7 Then GoTo 702
    If i = 10 Then GoTo 703
 
 
80  If Mid(k, s - i + 1, 1) = 1 Then Text4.Text = Text4.Text + " Одна"
    If Mid(k, s - i + 1, 1) = 2 Then Text4.Text = Text4.Text + " Две"
    If Mid(k, s - i + 1, 1) = 3 Then Text4.Text = Text4.Text + " Три"
    If Mid(k, s - i + 1, 1) = 4 Then Text4.Text = Text4.Text + " Четыре"
    If Mid(k, s - i + 1, 1) = 5 Then Text4.Text = Text4.Text + " Пять"
    If Mid(k, s - i + 1, 1) = 6 Then Text4.Text = Text4.Text + " Шесть"
    If Mid(k, s - i + 1, 1) = 7 Then Text4.Text = Text4.Text + " Семь"
    If Mid(k, s - i + 1, 1) = 8 Then Text4.Text = Text4.Text + " Восемь"
    If Mid(k, s - i + 1, 1) = 9 Then Text4.Text = Text4.Text + " Девять"
    If i = 4 Then GoTo 704
    GoTo 20

90  If Mid(k, s - i + 1, 2) = 11 Then Text4.Text = Text4.Text + " Одиннадцать"
    If Mid(k, s - i + 1, 2) = 12 Then Text4.Text = Text4.Text + " Двенадцать"
    If Mid(k, s - i + 1, 2) = 13 Then Text4.Text = Text4.Text + " Тринадцать"
    If Mid(k, s - i + 1, 2) = 14 Then Text4.Text = Text4.Text + " Четырнадцать"
    If Mid(k, s - i + 1, 2) = 15 Then Text4.Text = Text4.Text + " Пятнадцать"
    If Mid(k, s - i + 1, 2) = 16 Then Text4.Text = Text4.Text + " Шестнадцать"
    If Mid(k, s - i + 1, 2) = 17 Then Text4.Text = Text4.Text + " Семнадцать"
    If Mid(k, s - i + 1, 2) = 18 Then Text4.Text = Text4.Text + " Восемнадцать"
    If Mid(k, s - i + 1, 2) = 19 Then Text4.Text = Text4.Text + " Девятнадцать"
    If Mid(k, s - i + 1, 2) = 10 Then Text4.Text = Text4.Text + " Десять"
    If i = 5 Then Text4.Text = Text4.Text + " тысяч"
    If i = 8 Then Text4.Text = Text4.Text + " миллионов"
    If i = 11 Then Text4.Text = Text4.Text + " миллиардов"
    If i = 2 Then
        Text4.Text = Text4.Text + " рублей"
        If InStr(k, "-") > 0 Then GoTo 600
    End If
    i = i - 2
    GoTo 20
 
 
600 Text4.Text = Text4.Text + " " + Right(k, 2)
    If Right(k, 1) = 2 Then Text4.Text = Text4.Text + " копейки"
    If Right(k, 1) = 3 Then Text4.Text = Text4.Text + " копейки"
    If Right(k, 1) = 4 Then Text4.Text = Text4.Text + " копейки"
    If Right(k, 1) = 1 Then Text4.Text = Text4.Text + " копейкa"
    If Right(k, 1) = 0 Then Text4.Text = Text4.Text + " копеек"
    If Right(k, 1) > 4 Then Text4.Text = Text4.Text + " копеек"
 
    Exit Sub
 
701 If Mid(k, s - i + 1, 1) = 2 Then Text4.Text = Text4.Text + " рубля"
    If Mid(k, s - i + 1, 1) = 3 Then Text4.Text = Text4.Text + " рубля"
    If Mid(k, s - i + 1, 1) = 4 Then Text4.Text = Text4.Text + " рубля"
    If Mid(k, s - i + 1, 1) = 1 Then Text4.Text = Text4.Text + " рубль"
    If Mid(k, s - i + 1, 1) > 4 Then Text4.Text = Text4.Text + " рублей"
    If Left(k, s) = 0 Then
        If InStr(k, "-") > 0 Then
            Text4.Text = Text4.Text + "Ноль рублей"
            GoTo 600
        End If
        If InStr(k, "-") = 0 Then Exit Sub
    End If
    If Mid(k, s - i + 1, 1) = 0 Then Text4.Text = Text4.Text + " рублей"
    If InStr(k, "-") > 0 Then GoTo 600
 
    Exit Sub

702 If Mid(k, s - i + 1, 1) = 2 Then Text4.Text = Text4.Text + " миллиона"
    If Mid(k, s - i + 1, 1) = 3 Then Text4.Text = Text4.Text + " миллиона"
    If Mid(k, s - i + 1, 1) = 4 Then Text4.Text = Text4.Text + " миллиона"
    If Mid(k, s - i + 1, 1) = 1 Then Text4.Text = Text4.Text + " миллион"
    If Mid(k, s - i + 1, 1) > 4 Then Text4.Text = Text4.Text + " миллионов"
    If Mid(k, s - i + 1, 1) = 0 Then
        If n(7) + n(8) + n(9) > 0 Then Text4.Text = Text4.Text + " миллионов"
    End If
    i = i - 1
    GoTo 20
 
703 If Mid(k, s - i + 1, 1) = 2 Then Text4.Text = Text4.Text + " миллиарда"
    If Mid(k, s - i + 1, 1) = 3 Then Text4.Text = Text4.Text + " миллиарда"
    If Mid(k, s - i + 1, 1) = 4 Then Text4.Text = Text4.Text + " миллиарда"
    If Mid(k, s - i + 1, 1) = 1 Then Text4.Text = Text4.Text + " миллиард"
    If Mid(k, s - i + 1, 1) > 4 Then Text4.Text = Text4.Text + " миллиардов"
    If Mid(k, s - i + 1, 1) = 0 Then
        If n(10) + n(11) + n(12) > 0 Then Text4.Text = Text4.Text + " миллиардов"
    End If
    i = i - 1
    GoTo 20
 
704 If Mid(k, s - i + 1, 1) = 2 Then Text4.Text = Text4.Text + " тысячи"
    If Mid(k, s - i + 1, 1) = 3 Then Text4.Text = Text4.Text + " тысячи"
    If Mid(k, s - i + 1, 1) = 4 Then Text4.Text = Text4.Text + " тысячи"
    If Mid(k, s - i + 1, 1) = 1 Then Text4.Text = Text4.Text + " тысяча"
    If Mid(k, s - i + 1, 1) > 4 Then Text4.Text = Text4.Text + " тысяч"
    If Mid(k, s - i + 1, 1) = 0 Then
        If n(4) + n(5) + n(6) > 0 Then Text4.Text = Text4.Text + " тысяч"
    End If
    i = i - 1
    GoTo 20
 
 
ErrorInput:

    If MsgBox("Неправильный формат введенной суммы", vbCritical, "Ошибка формата") = vbOK Then Exit Sub
 
End Sub
 

 

Hosted by uCoz