Basically your code makes no sense...
txtDays
is, I presume, a regular
TextBox[
^] that is probably not validated. But let's assume, for this example,
txtDays
can only hold numeric values.
If the number of days entered is negative you show a
MessageBox[
^], may I suggest using the
MessageBox.Show Method[
^] (.NET) instead of
MsgBox[
^] (VB).
The next part of your code is a
Select Case Statement[
^] which checks for the value of the
days
variable. However,
days
is never set and thus will always be 0.
So now, let's say
days
IS set somewhere, you then show the amount of pounds this person has to pay. Well, I would certainly wait with returning my books, because after 20 days I only get a MessageBox and appearently don't have to pay for anything :)
The next part of your code is just the weirdest... You're saying
latecharge
is equal to
days
(which still isn't set) and then
txtLate.Text
is equal to
latecharge
... You might as well set
txtLate.Text
to days immediately. However, since you are using this
TextBox
to show the fee this person has to pay you are overwriting that value... Besides, the user already knows the days because he or she entered this himself! Also, your total variable does nothing and is just sitting there.
Now consider this:
Dim daysLate As Integer
If Not Integer.TryParse(txtDays.Text, daysLate) Then
MessageBox.Show("Please enter a numeric value.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
If daysLate < 0 Then
MessageBox.Show("Please enter a value higher than 0.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
Select Case days
Case 1 To 5
txtLate.Text = "2"
Case 6 To 10
txtLate.Text = "5"
Case 11 To 15
txtLate.Text = "7.5"
Case 16 To 20
txtLate.Text = "10"
Case Is > 20
MessageBox.Show("This member has exceeded the maximum number of days late.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
End Select
End If
End If
Now this would work, however... If the library is going to use different fees or days you will have to rewrite your software and re-deploy! So I suggest you store the days and fees in a database somewhere and recover them here...
However, since you seem to be quite lost as to what to do and how to do it I suggest you start reading some books first. There is plenty of reference material, both on the internet and in the library you are writing this software for.
By the way, is this homework? If it is I suggest you study a bit harder :)