编写VBA程序以在预订航班时保存详细信息。
Private Sub AdultSpinButton_Change()
AdultTextBox.Text = AdultSpinButton.Value
End Sub
Private Sub BookCommandButton_Click()
Application.ScreenUpdating = False
Dim NewemptyRow As Long
Sheet3.Activate
NewemptyRow = WorksheetFunction.CountA(Range(“A:A”)) + 1
Cells(NewemptyRow, 1).Value = NameTextBox.Value
Cells(NewemptyRow, 2).Value = MobileComboBox.Value
If RoundOptionButton.Value = True Then
Cells(NewemptyRow, 3).Value = “Round Trip”
Else
Cells(NewemptyRow, 3).Value = “One Way”
End If
Cells(NewemptyRow, 4).Value = FormComboBox.Value
Cells(NewemptyRow, 5).Value = ToComboBox.Value
Cells(NewemptyRow, 6).Value = DepartComboBox.Value
Cells(NewemptyRow, 7).Value = ReturnComboBox.Value
Cells(NewemptyRow, 8).Value = AdultTextBox.Value
Cells(NewemptyRow, 9).Value = ChildTextBox.Value
If StudentOptionButton.Value = True Then
Cells(NewemptyRow, 10).Value = “Student”
Else
Cells(NewemptyRow, 10).Value = “Armed Forces”
Else
Cells(NewemptyRow, 10).Value = “Sr.Citizen”
End If
Cells(NewemptyRow, 11).Value = PromoTextBox.Value
Cells(NewemptyRow, 12).Value = CurrencyComboBox.Value
Sheet2.Activate
Unload Me
Application.ScreenUpdating = True
End Sub
Private Sub CancelCommandButton_Click()
Unload Me
End Sub
Private Sub ChildSpinButton_Change()
ChildTextBox.Text = ChildSpinButton.Value
End Sub
Private Sub ClearCommandButton_Click()
Call Userform_Initialize
End Sub
Private Sub Userform_Initialize()
NameTextBox = ” “
MobileTextBox = ” “
RoundOptionButton.Value = False
OnewayOptionButton.Value = False
With FomComboBox
.AddItem “Delhi”
.AddItem “Hyderabad”
.AddItem “Mumbai”
.AddItem “Bangalore”
.AddItem “Pune”
.AddItem “Chennai”
.AddItem “Kolkata”
.AddItem “Lucknow”
End With
With ToComboBox
.AddItem “Delhi”
.AddItem “Hyderabad”
.AddItem “Mumbai”
.AddItem “Bangalore”
.AddItem “Pune”
.AddItem “Chennai”
.AddItem “Kolkata”
.AddItem “Lucknow”
End With
With DepartComboBox
.AddItem “1/month(today())/year(today())”
.AddItem “2/month(today())/year(today())”
.AddItem “3/month(today())/year(today())”
.AddItem “4/month(today())/year(today())”
.AddItem “5/month(today())/year(today())”
.AddItem “6/month(today())/year(today())”
End With
AdultTextBox.Value = ” “
ChildTextBox.Value = ” “
StudentOptionButton.Value = False
ArmedOptionButton.Value = False
SrCitizenOptionButton.Value = False
PromoTextBox = ” “
With CurrencyComboBox
.AddItem “Indian Rupees”
.AddItem “US Dollars”
End With
End Sub
“ CommandButton代码”
Private Sub BookFlight_Click()
BookAFlight.Show
End Sub
当我单击命令按钮时,它会给我:
运行时错误424“需要对象”
我无法调试我的问题,任何人都可以帮我解决这个问题。