Airline Reservation System Begginer Help! urgent!

need a USER DEFINED FUNCTION in this program (code posted)

Page 1 of 1

4 Replies - 3195 Views - Last Post: 28 January 2009 - 09:28 AM Rate Topic: -----

#1 artemster  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 13-January 09

Airline Reservation System Begginer Help! urgent!

Posted 18 January 2009 - 09:50 PM

Option Explicit
Const intFirstCost As Integer = 350
Const intSecondCost As Integer = 200
Const intThirdCost As Integer = 100

Const intRussiaCost As Integer = 500
Const intMexicoCost As Integer = 350
Const intUsaCost As Integer = 200
Const intCubaCost As Integer = 250

Dim intFirstClass As Integer
Dim intSecondClass As Integer
Dim intThirdClass As Integer

Dim intNumberofSeats1 As Integer
Dim intNumberofSeats2 As Integer
Dim intNumberofSeats3 As Integer

Dim intTotal As Integer

Private Sub Cmbdestinations_Click()

If intNumberofSeats1 = Txtnumseats.Text And Cmbdestinations.Text = "Moscow,Russia" Then
intTotal = intNumberofSeats1 * (intFirstCost + intRussiaCost)
ElseIf intNumberofSeats1 = Txtnumseats.Text And Cmbdestinations.Text = "Washington,Usa" Then
intTotal = intNumberofSeats1 * (intFirstCost + intUsaCost)
ElseIf intNumberofSeats1 = Txtnumseats.Text And Cmbdestinations.Text = "Havana,Cuba" Then
intTotal = intNumberofSeats1 * (intFirstCost + intCubaCost)
ElseIf intNumberofSeats1 = Txtnumseats.Text And Cmbdestinations.Text = "Mexico city,Mexico" Then
intTotal = intNumberofSeats1 * (intFirstCost + intMexicoCost)

ElseIf intNumberofSeats2 = Txtnumseats.Text And Cmbdestinations.Text = "Moscow,Russia" Then
intTotal = intNumberofSeats2 * (intSecondCost + intRussiaCost)
ElseIf intNumberofSeats2 = Txtnumseats.Text And Cmbdestinations.Text = "Washington,Usa" Then
intTotal = intNumberofSeats2 * (intSecondCost + intUsaCost)
ElseIf intNumberofSeats2 = Txtnumseats.Text And Cmbdestinations.Text = "Havana,Cuba" Then
intTotal = intNumberofSeats2 * (intSecondCost + intCubaCost)
ElseIf intNumberofSeats2 = Txtnumseats.Text And Cmbdestinations.Text = "Mexico city,Mexico" Then
intTotal = intNumberofSeats2 * (intSecondCost + intMexicoCost)

ElseIf intNumberofSeats3 = Txtnumseats.Text And Cmbdestinations.Text = "Moscow,Russia" Then
intTotal = intNumberofSeats3 * (intThirdCost + intRussiaCost)
ElseIf intNumberofSeats3 = Txtnumseats.Text And Cmbdestinations.Text = "Washington,Usa" Then
intTotal = intNumberofSeats3 * (intThirdCost + intUsaCost)
ElseIf intNumberofSeats3 = Txtnumseats.Text And Cmbdestinations.Text = "Havana,Cuba" Then
intTotal = intNumberofSeats3 * (intThirdCost + intCubaCost)
ElseIf intNumberofSeats3 = Txtnumseats.Text And Cmbdestinations.Text = "Mexico city,Mexico" Then
intTotal = intNumberofSeats3 * (intThirdCost + intMexicoCost)

End If
End Sub

Private Sub cmdtotal_Click()
lbltotalprice.Caption = Format(intTotal, "currency")
End Sub

Private Sub Form_Load()
Randomize
intFirstClass = Int(3 * Rnd + 1)
lblseats1.Caption = intFirstClass
intSecondClass = Int(12 * Rnd + 3)
lblseats2.Caption = intSecondClass
intThirdClass = Int(15 * Rnd + 15)
lblseats3.Caption = intThirdClass

Cmbdestinations.AddItem "Moscow,Russia"
Cmbdestinations.AddItem "Washington,Usa"
Cmbdestinations.AddItem "Havana,Cuba"
Cmbdestinations.AddItem "Mexico City, Mexico"
End Sub

Private Sub optfirst_Click()
Txtnumseats.Text = ""
Cmbdestinations.Text = "Destinations"
End Sub

Private Sub optsecond_Click()
Txtnumseats.Text = ""
Cmbdestinations.Text = "Destinations"
End Sub

Private Sub optthird_Click()
Txtnumseats.Text = ""
Cmbdestinations.Text = "Destinations"
End Sub

Private Sub Txtnumseats_Change()
Cmbdestinations.Text = "Destinations"
If Txtnumseats.Text = "" Then
Exit Sub
End If
If optfirst.Value = True Then
intNumberofSeats1 = Txtnumseats.Text
	If intNumberofSeats1 > intFirstClass Then
	intNumberofSeats1 = intFirstClass
	Txtnumseats.Text = intNumberofSeats1
	End If
ElseIf optsecond.Value = True Then
intNumberofSeats2 = Txtnumseats.Text
	If intNumberofSeats2 > intSecondClass Then
	intNumberofSeats2 = intSecondClass
	Txtnumseats.Text = intNumberofSeats2
	End If
ElseIf optthird.Value = True Then
intNumberofSeats3 = Txtnumseats.Text
	If intNumberofSeats3 > intThirdClass Then
	intNumberofSeats3 = intThirdClass
	Txtnumseats.Text = intNumberofSeats3
	End If
Else
MsgBox "Please select a class"
Txtnumseats.Text = ""
End If
lbltotalprice.Caption = ""
End Sub





AS you can see, i have have made an effort to make this program, it works however i do not think it
is "user friendly enough" because you can only choose in 1 order (1.class 2. num of seats, 3. destination), and if you choose in any other order there will be an error. Can someone show me how fix that.

Also, i need a "user defined" function in there, but do not know how to do that since i am a begginer.

IT WILL BE VERY APRRICIATIVE IF YOU PLEASE HELP QUICK!!!

to see screenshot of the INTERFACE copy and paste this to you're address bar
http://img413.images...nterfacefw2.png

This post has been edited by artemster: 18 January 2009 - 10:34 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Airline Reservation System Begginer Help! urgent!

#2 emkaye  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 12-August 07

Re: Airline Reservation System Begginer Help! urgent!

Posted 19 January 2009 - 03:46 PM

i'm also doing an airline reservation system with database.in your case, you are not using one.but i think i can help in someway.

and one thing more, may i know the error please?

:)
Was This Post Helpful? 0
  • +
  • -

#3 artemster  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 13-January 09

Re: Airline Reservation System Begginer Help! urgent!

Posted 19 January 2009 - 09:30 PM

View Postemkaye, on 19 Jan, 2009 - 02:46 PM, said:

i'm also doing an airline reservation system with database.in your case, you are not using one.but i think i can help in someway.

and one thing more, may i know the error please?

:)




There is no actual error, and program works fine. However i am a begginer to visual basic, and need help in improving this program, as it is pretty simple and will not achieve a good mak. One of the main things i need help with, is imputing a "user defined" function (not exactly sure how that works either) into the program. Now i know this program really does not need a "user defined" function, however it is a part of the requirements. I thought of making this function give discounts on certain tickets, as "deals", but i am not sure how to do that and need help.
Was This Post Helpful? 0
  • +
  • -

#4 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: Airline Reservation System Begginer Help! urgent!

Posted 21 January 2009 - 06:04 PM

make all your operation in a seperate function or sub and call this thing from from option click textbox changed,leave and combobox selection changed
and moreover select any one option button and any one item in combobox

this will solve your problem
Was This Post Helpful? 0
  • +
  • -

#5 emkaye  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 12-August 07

Re: Airline Reservation System Begginer Help! urgent!

Posted 28 January 2009 - 09:28 AM

Okies. . .

To give you an idea with the function thingy, here's one from my codes:

Public Function NextComm()
		
		If AdultCnt > 1 Then
			frmBook3.cmdNextA.Enabled = True
		Else
			frmBook3.cmdNextA.Enabled = False
		End If

End Function



1.You start with Public Function
2.then the "NextComm" you see there- I just defined it myself.This is likely to be the name of the function you made.You can have any word you want.
3.Inside the function, as you can see, is an elseif statement,this is what the function will do when you call it. well, you can use other statements aside from the elseif. It's up to you.
4.end function-simply type End Function :)

In my case, I put my function on my module. It's just what I wanted so that I can just call it on any forms I wish.

Now, when you want to call the function, say for example on a command button on one form, on the click event of the command button, just simply type "Call NextComm" or "NextComm" (without the double quotes).

And, your done! : ^:

I hope this helps..

I'm not a pro in vb6 but this is what I usually do in my programs..

Comments are welcomed :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1