hi everyone
i'm sorry i know i am asking simple questions but i really cannot understand the problem with my code
here i wrote a code for the cash register
( except two buttons : clear and delete )
but it doesn't work
i think something is wrong with the conversions i made
can somebody please tell me what's wrong?!!

Public Class Form1
    Dim num As Double
    Dim Tax As Double
    Dim subtotal As Double = 0


    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click
        Label1.Text = Label1.Text & "7"
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click
        Label1.Text = Label1.Text & "9"
    End Sub

    Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
        Label1.Text = Label1.Text & "1"
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
        Label1.Text = Label1.Text & "2"
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click
        Label1.Text = Label1.Text & "4"
    End Sub

    Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click
        Label1.Text = Label1.Text & "3"
    End Sub

    Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click
        Label1.Text = Label1.Text & "5"
    End Sub

    Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click
        Label1.Text = Label1.Text & "6"
    End Sub

    Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click
        Label1.Text = Label1.Text & "8"
    End Sub

    Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click
        Label1.Text = Label1.Text & "0"
    End Sub

    Private Sub btnDot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDot.Click
        Label1.Text = Label1.Text & "."
    End Sub
'problem is here
    Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click
        subtotal = CDbl(txtSubtotal.Text)
        txtSubtotal.Text = CStr(num + subtotal)
        Label1.Text = ""


    End Sub

    Private Sub btnTotal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTotal.Click
        num = CInt(Label1.Text)
        If num > 500 Then
            Tax = 0.1 * num
        Else
            If Tax > 100 Then
                Tax = 0.75 * num
            Else
                Tax = 0.05 * num
            End If
        End If
        txtTax.Text = Tax
        txtTotal.Text = Tax + num
    End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click

    End Sub

    Private Sub txtSubtotal_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSubtotal.TextChanged


    End Sub
End Class
subtotal = CDbl(txtSubtotal.Text)

i dont see anywhere in your code that u actually set this txtSubtotal.Text before using it.

num = CInt(Label1.Text)

that should be CDbl(Label1.Text)

hi
tnx so much
but actually i didnt get what u mean about txtSubtotal.text
should i define it as a variable?!
like :

Dim Subtotal As Double = CDbl (txtSubtotal.Text)

no. i just wonder where this textbox/Label gets its content from. i doubt you want the user to enter the subtotal. but in your code i dont see where you set ever the content of that control. so based on your code the content of this control is NOTHING

tnx!!!!!!!!!!!!!!!!!!!!! finally solved it!! tnx so much! yeah ur right i corrected it..!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.