Visual Basic Help Plz

Charlie

Board Regular
Joined
Mar 1, 2002
Messages
134
I am using this code to produce an APP that is supposed to calc the travel cost of a family with 2 adults and 2 children.
The adult charge is 70 and the child price is 30 if the child is under 13, under the age of 2 travel free.
What I am looking to do is find a better way to show the adult price and achieve a total cost.

Private Sub cmdQUIT_Click()
'Terminate Application
End
End Sub

Private Sub cmdStart_Click()
'Declare required storage
Dim Child_Age As Integer
Dim Child_Age2 As Integer
Dim Adult_Pri As Integer

'Ask user what age their children are


Child_Age = InputBox("How old is your first child ", "What Age")
Child_Age2 = InputBox("How old is your second child ", "What Age")

Select Case Child_Age
Case Is <= 2
picMessage.Print "The First Child price is Free"
Case Is < 13
picMessage.Print "The First Child price is 30 Pounds"
Case Is >= 13
picMessage.Print "The First Child price is 70 Pounds"
End Select


Select Case Child_Age2
Case Is <= 2
picMessage.Print "The Second Child price is Free"
Case Is < 13
picMessage.Print "The Second Child price is 30 Pounds"
Case Is >= 13
picMessage.Print "The Second Child price is 70 Pounds"
End Select
Adult_Pri = 70
'Display message in picture box
picMessage.Print "The price per adult is " & Adult_Pri; " "; "Pounds"

End Sub

Can anyone gimme a piece of advice please.

Thanks
Charlie
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Here ya go Charlie.
<pre>
Private Sub cmdStart_Click()
'Declare required storage
Dim Child_Age As Integer
Dim Child_Age2 As Integer
Dim Adult_Pri As Integer
Dim Child_Price(1 To 2) As Integer

'Ask user what age their children are


Child_Age = InputBox("How old is your first child ", "What Age")
Child_Age2 = InputBox("How old is your second child ", "What Age")

Select Case Child_Age
Case Is <= 2
picMessage.Print "The First Child price is Free"
Child_Price(1) = 0
Case Is < 13
picMessage.Print "The First Child price is 30 Pounds"
Child_Price(1) = 30
Case Is >= 13
picMessage.Print "The First Child price is 70 Pounds"
Child_Price(1) = 70
End Select


Select Case Child_Age2
Case Is <= 2
Case Is <= 2
picMessage.Print "The Second Child price is Free"
Child_Price(2) = 0
Case Is < 13
picMessage.Print "The Second Child price is 30 Pounds"
Child_Price(2) = 30
Case Is >= 13
picMessage.Print "The Second Child price is 70 Pounds"
Child_Price(2) = 70
End Select

Adult_Pri = 70

'Display message in picture box
picMessage.Print "The price per adult is " & Adult_Pri; " "; "Pounds"
picMessage.Print Chr(13) & "Your total cost is " & _
Child_Price(1) + Child_Price(2) + Adult_Pri; " "; "Pounds"
End Sub

</pre>
Tom
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,752
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top