IF statement problem

bobmack37

Newcomer
Joined
Apr 22, 2003
Messages
12
Ok I want to write an IF statement that says I am selling copys at 0.05 a copy for the 1st 100 but then after that each additional copy is 0.03. with my code I can get 25 copys to be 1.25 but when I enter 125 copys I get 3.75 and I know I should get 5.75 I am not sure where I went wrong here I know it is simple I am just stumped I am missing some math but don't know where to put it. :(

Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
Dim number As Single
Dim cost As Single
number = Val(InputBox("Number of copies:"))
If number <= 100 Then
cost = 0.05 * number
ElseIf number > 100 Then
cost = 0.03 * number
End If
txtTotcopies.Text = "The cost is " & FormatCurrency(cost) & "."
End Sub
End Class
 
Visual Basic:
Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
    Dim number As Single
    Dim cost As Single
    number = Val(InputBox("Number of copies:"))
    If number <= 100 Then
        cost = 0.05 * number
    ElseIf number > 100 Then
        cost = 5.00 + (0.03 * (number - 100)) '<-- change
    End If
    txtTotcopies.Text = "The cost is " & FormatCurrency(cost) & "."
End Sub
 
Back
Top