8 Replies - 1206 Views - Last Post: 16 February 2010 - 07:45 AM Rate Topic: -----

#1 Guest_Fortran*


Reputation:

vb 6.0 project help

Posted 15 February 2010 - 07:17 PM

Hey guys i have a vb project due in real soon and i really need some help. The premise for the project is a holiday booking program. The user can select a holiday on one form and optional extras on another form. My main problem is that i just dont know how to carry the total of the cost of the holiday over to the extras form and from there to the finalisation form. My code for the holiday form is this:

Private Sub TxtAdults_Change()
TxtAdults.Text = InputBox("Please input number of adult tickets needed.")
End Sub

Private Sub TxtKids_change()
TxtKids.Text = InputBox("Please input number of kids tickets needed.")
End Sub
Private Sub LblTotal_Click()
LblTotal = (LblAdultPrice * TxtAdults) + (LblKidsPrice * TxtKids)
End Sub

Private Sub Cmd_Extras_Click()
Frm_tours.Hide
Frm_Extras.Show
End Sub



Basically i want to carry the amount on LblTotal onto my next form. How can i do this?

Thanks Guys.

Fortran
Mod Edit:
Added in code tags. When posting code, please use tags like below. Thanks.
:code:

Is This A Good Question/Topic? 0

Replies To: vb 6.0 project help

#2 Guest_Fortran*


Reputation:

Re: vb 6.0 project help

Posted 15 February 2010 - 07:18 PM

View PostFortran, on 15 February 2010 - 06:17 PM, said:

Hey guys i have a vb project due in real soon and i really need some help. The premise for the project is a holiday booking program. The user can select a holiday on one form and optional extras on another form. My main problem is that i just dont know how to carry the total of the cost of the holiday over to the extras form and from there to the finalisation form. My code for the holiday form is this:


Private Sub TxtAdults_Change()
TxtAdults.Text = InputBox("Please input number of adult tickets needed.")
End Sub

Private Sub TxtKids_change()
TxtKids.Text = InputBox("Please input number of kids tickets needed.")
End Sub
Private Sub LblTotal_Click()
LblTotal = (LblAdultPrice * TxtAdults) + (LblKidsPrice * TxtKids)
End Sub

Private Sub Cmd_Extras_Click()
Frm_tours.Hide
Frm_Extras.Show
End Sub

Basically i want to carry the amount on LblTotal onto my next form. How can i do this?

Thanks Guys.

Fortran

Was This Post Helpful? 0

#3 vb5prgrmr  Icon User is offline

  • D.I.C Lover

Reputation: 109
  • View blog
  • Posts: 1,016
  • Joined: 21-March 09

Re: vb 6.0 project help

Posted 15 February 2010 - 07:48 PM

NextForm.PublicVariable = PreviousForm.Label1.Caption





Good Luck
Was This Post Helpful? 0
  • +
  • -

#4 Guest_Fortran*


Reputation:

Re: vb 6.0 project help

Posted 15 February 2010 - 07:56 PM

View Postvb5prgrmr, on 15 February 2010 - 06:48 PM, said:

NextForm.PublicVariable = PreviousForm.Label1.Caption





Good Luck


Thanks i will try to figure how to use this. does anyone else have other methods of declaring intTotal as a global variable and calling it?
Was This Post Helpful? 0

#5 Guest_f*


Reputation:

Re: vb 6.0 project help

Posted 15 February 2010 - 07:59 PM

View Postvb5prgrmr, on 15 February 2010 - 06:48 PM, said:

NextForm.PublicVariable = PreviousForm.Label1.Caption





Good Luck


When I enter Frm_Extras.intTotal = Frm_tours.LblTotal.Caption, I keep getting an invalid outside procedure error.
Was This Post Helpful? 0

#6 Kinwang2009  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 76
  • Joined: 07-February 10

Re: vb 6.0 project help

Posted 16 February 2010 - 12:24 AM

Hi,

Here is my simple help.

On your Frm_tours use the below code

Option Explicit
Public strAmount

On Unload/any event you type the below code.

strAmount = LblTotal.Caption

Then on your Frm_Extras use the below code

Private Sub Form_Load()
intTotal = Frm_tour.strAmount
End Sub

Hope this helps
Was This Post Helpful? 0
  • +
  • -

#7 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 465
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: vb 6.0 project help

Posted 16 February 2010 - 03:20 AM

hello :)
@Kinwang2009
i think that when you unload the form variable strAmount will be empty.
@Guest_Fortran
if you want to pass the value to a new form try this add a public variable in the new form like so
Option Explicit
Public MyVar as String



then in the old form when you call the new form
Dim MyNewForm As New My_New_Form
MyNewForm.MyVar=Label1.Caption
MyNewForm.Show



good luck
Was This Post Helpful? 0
  • +
  • -

#8 vb5prgrmr  Icon User is offline

  • D.I.C Lover

Reputation: 109
  • View blog
  • Posts: 1,016
  • Joined: 21-March 09

Re: vb 6.0 project help

Posted 16 February 2010 - 06:42 AM

Actually NoBrain, when you unload a form, you are only unloading graphical elements of the form, which means any procedures or variables that are public are still available. For an example start a new standard exe program, add a button to form1 (command1) and add the following code...
Option Explicit

Private Sub Command1_Click()

On Error GoTo Command1_ClickError

Form2.Show
Unload Form2
MsgBox Form2.MyPublicForm2StringVariable
Set Form2 = Nothing
MsgBox Form2.MyPublicForm2StringVariable

Exit Sub
Command1_ClickError:

MsgBox "Command1_Click " & Err.Number & ":" & Err.Description

End Sub



Now add a form (form2) and add the following code...

Option Explicit

Public MyPublicForm2StringVariable As String

Private Sub Form_Load()
MyPublicForm2StringVariable = "This is a test"
End Sub



Press F5 to run and click on command button...



Good Luck
Was This Post Helpful? 1
  • +
  • -

#9 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 465
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: vb 6.0 project help

Posted 16 February 2010 - 07:45 AM

hmm so i got to change a few codes now :P ty for the explanation dude :)

This post has been edited by NoBrain: 16 February 2010 - 07:46 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1