This is the problem I am working on ( you have likely seen it before)
A bank charges $10 per month, plus the following check fees for a commercial
checking account:
$0.10 each for less than 20 checks
$0.08 each for 20 through 39 checks
$0.06 each for 40 through 59 checks
$0.04 each for 60 or more checks
Create an application that allows the user to enter the number of checks written.
The application should compute and display the bank’s service fees for the month.
All checks for the month are assigned the same charge, based on the total number of
checks written during the month.
Input validation: Do not accept a negative value for the number of checks written.
Ensure that all values are numeric. The Clear button must clear the text box and the
label that displays the monthly service charge.
Use the following test data to determine if the application is calculating properly. In
each case, the customer is charged only a single rate, based on the total number of
checks:

I am attempting right now to do the calculation part of the problem and thus far what I am getting is something like this
Type value into a textbox and then the program attempts to calculate the problem well i get no calculation , all it does is insert 0's into both the textbox and the label. I think I am perhaps missing something simple here to have it calculate correctly , any help or insight would be appreciated .

Dim checks As Double
        Dim Fee As Double
        Dim Q As Integer
        If checks < 20 Then
            Fee = checks * 0.1
        ElseIf checks < 39 Then
            Fee = checks * 0.08 + 1.9
        ElseIf checks < 59 Then
            Fee = checks * 0.8 + 1.9
        ElseIf checks < 60 Then
            Fee = checks * 0.8 + 1.9
        End If
        Q = CDbl(TextBox1.Text) * (Fee)
        TextBox1.Text = checks
        Label3.Text = CStr(Q)

Hmm ok well that fixes the issue of it displaying only zero's now I just need to figure out where my math is messing up. Example being 33 checks= 63 which is obviously incorrect ._.

(new code)

 Dim checks As Double
        Dim Fee As Double
        Dim Q As Integer
        If checks > 1 And checks < 20 Then
            Fee = checks * 0.1
        ElseIf checks > 21 And checks < 39 Then
            Fee = checks * 0.08 + 1.9
        ElseIf checks > 40 And checks < 59 Then
            Fee = checks * 0.8 + 1.9
        ElseIf checks < 60 Then
            Fee = checks * 0.8 + 1.9
        End If
        Q = CDbl(TextBox1.Text) * (Fee)
        TextBox1.Text = checks
        Label3.Text = CStr(Q)

This is for when a button is clicked, its suppose to calculate the check fee. and this is all the code that goes into the button.

You can't use checks to count the clicks. This could be anything. You need to setup a proper counter tha tincreases each time th bvutton is clicked. Use the button.click eventhandler for this.

Did you notice that if the number of checks written is >= 60 you don't do a calculation? You might want to consider a case statement which is simpler and clearer.

Select Case checks
    Case 0 To 19
        fee = 0.1
    Case 20 To 39
        fee = 0.08
    Case 40 To 59
        fee = 0.06
    Case Else '60 or more
        fee = 0.04
End Select

That Case statement does indeed change it from 10 to 10.1 so that leaves the problem being the fact that I have no clue how to make a case statement multiply by the number of checks.

That Case statement does indeed change it from 10 to 10.1

I don't understand this statement. As for the multiplication, you do that after the select-case by

checks * fee

and assuming you have done the validity checks, before the select-case you should have

 Dim checks As Double = CInt(TextBox1.Text)

I strongly suggest you get into the habit of naming your controls. For example txtNumChecks instead of TextBox1.

@Jim
shouldn't that be Dim checks As Double = CDbl(TextBox1.Text) also OP has 2 threads now for the same topic

Edited 2 Years Ago by Minimalist

Actually, that should have been

Dim checks As Integer = CInt(TextBox1.Text)

I had copied part of the code from the OP's original post without thinking about it.

Edited 2 Years Ago by Reverend Jim

This question has already been answered. Start a new discussion instead.