Dim x As Long

Private Sub Command1_Click()

    Text3 = Val(Text2) - Val(Text1)
    
    x = Val(Text3) * 100

    If x > 0 Then

        If x / 2000 > 0 Then
            Text4(0) = Int(x / 2000)
            x = x - Val(Text4(0)) * 2000
        End If

        If x / 1000 > 0 Then
            Text4(1) = Int(x / 1000)
            x = x - Val(Text4(1)) * 1000
        End If

        If x / 500 > 0 Then
            Text4(2) = Int(x / 500)
            x = x - Val(Text4(2)) * 500
        End If

        If x / 200 > 0 Then
            Text4(3) = Int(x / 200)
            x = x - Val(Text4(3)) * 200
        End If

        If x / 100 > 0 Then
            Text4(4) = Int(x / 100)
            x = x - Val(Text4(4)) * 100
        End If

        If x / 50 > 0 Then
            Text4(5) = Int(x / 50)
            x = x - Val(Text4(5)) * 50
        End If

        If x / 20 > 0 Then
            Text4(6) = Int(x / 20)
            x = x - Val(Text4(6)) * 20
        End If

        If x / 10 > 0 Then
            Text4(7) = Int(x / 10)
            x = x - Val(Text4(7)) * 10
        End If

        If x / 5 > 0 Then
            Text4(8) = Int(x / 5)
            x = x - Val(Text4(8)) * 5
        End If

        If x / 2 > 0 Then
            Text4(9) = Int(x / 2)
            x = x - Val(Text4(9)) * 2
        End If

        If x / 1 > 0 Then
            Text4(10) = Int(x / 1)
            x = x - Val(Text4(10)) * 1
        End If

End If

End Sub

Private Sub Command2_Click()

    Text1 = ""
    Text2 = ""
    Text3 = ""

    For k = 0 To 10
        Text4(k).Text = "0"
    Next k

End Sub

Back to vb6 exercises