Hi there
i have a problem with my little calculator project, i did everything but i got stuck at the decimal place, What i want the calculator to do is to give out an error when a user try to put in morethan one decimal point eg. 12.30.30 or 12..30.
can somebody help me please.
regards
Marcus
here is my code
Private Sub btnOne_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOne.Click
If tbCal.Text = Nothing Then
MsgBox("Must have a TOTAL to calculate change")
Else
tbcalculate.Text = tbcalculate.Text & btnOne.Text
tbChange.Clear()
End If
End Sub
Private Sub btnTwo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTwo.Click
If tbCal.Text = Nothing Then
MsgBox("Must have a TOTAL to calculate change")
Else
tbcalculate.Text = tbcalculate.Text & btnTwo.Text
tbChange.Clear()
End If
End Sub
Private Sub btnThree_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThree.Click
If tbCal.Text = Nothing Then
MsgBox("Must have a TOTAL to calculate change")
Else
tbcalculate.Text = tbcalculate.Text & btnThree.Text
tbChange.Clear()
End If
End Sub
Private Sub btnFour_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFour.Click
If tbCal.Text = Nothing Then
MsgBox("Must have a TOTAL to calculate change")
Else
tbcalculate.Text = tbcalculate.Text & btnFour.Text
tbChange.Clear()
End If
End Sub
Private Sub btnFive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFive.Click
If tbCal.Text = Nothing Then
MsgBox("Must have a TOTAL to calculate change")
Else
tbcalculate.Text = tbcalculate.Text & btnFive.Text
tbChange.Clear()
End If
End Sub
Private Sub btnSix_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSix.Click
If tbCal.Text = Nothing Then
MsgBox("Must have a TOTAL to calculate change")
Else
tbcalculate.Text = tbcalculate.Text & btnSix.Text
tbChange.Clear()
End If
End Sub
Private Sub btnSeven_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSeven.Click
If tbCal.Text = Nothing Then
MsgBox("Must have a TOTAL to calculate change")
Else
tbcalculate.Text = tbcalculate.Text & btnSeven.Text
tbChange.Clear()
End If
End Sub
Private Sub btnEight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEight.Click
If tbCal.Text = Nothing Then
MsgBox("Must have a TOTAL to calculate change")
Else
tbcalculate.Text = tbcalculate.Text & btnEight.Text
tbChange.Clear()
End If
End Sub
Private Sub btnNine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNine.Click
If tbCal.Text = Nothing Then
MsgBox("Must have a TOTAL to calculate change")
Else
tbcalculate.Text = tbcalculate.Text & btnNine.Text
tbChange.Clear()
End If
End Sub
Private Sub btnZero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnZero.Click
If tbCal.Text = Nothing Then
MsgBox("Must have a TOTAL to calculate change")
ElseIf tbcalculate.Text = Nothing Then
MsgBox("Must not have Zero dollards to change")
Else
tbcalculate.Text = tbcalculate.Text & btnZero.Text
End If
End Sub
Private Sub btnDecimal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDecimal.Click
If tbCal.Text = Nothing Then
MsgBox("Must have a TOTAL to calculate change")
ElseIf tbcalculate.Text = Nothing Then
MsgBox("Must not have less than total amount")
Else
tbcalculate.Text = tbcalculate.Text & btnDecimal.Text
End If
DecimalFlag = True
End Sub
Private Sub btnChange_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChange.Click
If tbCal.Text = Nothing Then
MsgBox("Must have a TOTAL to calculate change")
ElseIf tbcalculate.Text = Nothing Then
MsgBox("Must have a Cash Amount to calculate change")
ElseIf total1 > tbcalculate.Text Then
MsgBox("Total can not be greater than Cash amount")
Else
cal1 = tbcalculate.Text - total1
tbChange.Text = FormatCurrency(cal1)
End If
tbcalculate.Text = 0
tbcalculate.Clear()
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
tbChange.Clear()
tbcalculate.Text = 0
tbcalculate.Clear()
End Sub