VB.NET按钮事件问题

时间:2010-04-18 23:36:37

标签: vb.net

我的按钮代码出现了按钮问题。

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

它处理:

' 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")
....

收到错误:

  

Handles子句需要在中定义一个WithEvents变量   包含类型或其基本类型之一。

1 个答案:

答案 0 :(得分:0)

btnCalculateCosts定义在哪里? - SLaks 14小时前