VBA Program

write a VBA program to save the details while booking a flight. 

 

I am done with my code but unable to run that code.

 

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 Code”

Private Sub BookFlight_Click()

BookAFlight.Show

End Sub

 

 

when I click on the command button It gives me runtime error 424 “Object required”, I am not able to debug my problem, can anyone help me with that.

By: Prabhav Sharma

Leave a Reply

Your email address will not be published. Required fields are marked *