VB.NET Button Issue

Posted by Michael on Stack Overflow See other posts from Stack Overflow or by Michael
Published on 2010-04-18T23:36:36Z Indexed on 2010/04/18 23:43 UTC
Read the original article Hit count: 151

Filed under:

I am having problem with a button the code of my button is.

    Private Sub btnCalculateCosts_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculateCosts.Click

it handles:

' This Calculate Costs button click event handler edits the ' registration(costs) form to ensure it contains valid data. ' Then, after passing control to the business class, it ' displays the registration cost.

        Dim objCourse As Course
        Dim objCourseCostsFile As Course
        Dim InputError As Boolean = False

   ' Is student ID entered properly
        If Me.txtCorporateID.MaskFull = False Then
            MessageBox.Show("Enter your Corporate ID in the Corporate ID box", _
            "Error")
            Me.txtCorporateID.Clear()
            Me.txtCorporateID.Focus()
            InputError = True
        ' Is student name entered properly
        ElseIf Me.txtFirstName.TextLength < 1 Or _
                Me.txtFirstName.Text < "A" Then
            MessageBox.Show("Please enter your first name in the First Name box", "Error")
            Me.txtFirstName.Clear()
            Me.txtFirstName.Focus()
            InputError = True
        ' Is number of units entered properly
        ElseIf Me.txtLastName.TextLength < 1 Or _
            Me.txtLastName.Text < "A" Then
            MessageBox.Show("Please enter your last name in the Last Name box", "Error")
            Me.txtLastName.Clear()
            Me.txtLastName.Focus()
            InputError = True
        ' Is number of units entered properly
        ElseIf Not IsNumeric(Me.txtNumberOfDays.Text) Then
            MessageBox.Show("Enter the units in the Number of Units box", _
            "Error")
            Me.txtNumberOfDays.Clear()
            Me.txtNumberOfDays.Focus()
            InputError = True
        ' Has 1-4 units been entered
            ElseIf Convert.ToInt32(Me.txtNumberOfDays.Text) < 1 _
            Or Convert.ToInt32(Me.txtNumberOfDays.Text) > 4 Then
            MessageBox.Show("Units must be 1 - 4", "Error")
            Me.txtNumberOfDays.Clear()
            Me.txtNumberOfDays.Focus()
            InputError = True

        End If



    ' If no input error, process the registration costs
        If Not InputError Then
            If Me.radPreConferenceCourse.Checked = False Then
                 objCourse = New Course(txtCorporateID.Text, txtFirstName.Text, txtLastName.Text, txtNumberOfDays.Text)
                Me.lblCosts.Visible = True
                Me.lblCosts.Text = "Total Conference Costs Are: " _
                  & (objCourse.ComputeCosts()).ToString("C2")
            Else
                objCourse = New Course(txtCorporateID.Text, txtFirstName.Text, txtLastName.Text, txtNumberOfDays.Text, g)
                Me.lblCosts.Visible = True
                Me.lblCosts.Text = "Total Conference Costs Are: " _
                & (objCourse.ComputeCosts()).ToString("C2")

Receiving the error: Handles clause requrieres a WithEvents variable defined in the containing type or one of its base types.

© Stack Overflow or respective owner

Related posts about vb.net