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

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
L

Legacy 98055

Guest
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
 

Forum statistics

Threads
1,144,293
Messages
5,723,560
Members
422,503
Latest member
aarifmahmood

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
Top