Hey all, this is my first post here, and I'm just going to dive into it.
I am taking an intro to computers class as a pre-requisite for a geology, and currently we are working on automations or whatever its called for excel using visual basic for applications. I have finished most of my project, however I am stuck on the last part of it. the instructions are as follows:
Create another Macro named Decision_Making.
The following code translates the flowchart information into an actual program. Type the following code after your last exercise displayed in the Code window of the Visual Basic Screen.
Sub Decision_Making
Dim age As Integer
age = InputBox("My age is")
If age > 18 Then
admission = 18
Else
admission = 10
End If
MsgBox ("My admission price is $" & admission & "")
End Sub
Execute the program by pressing F5. Enter any values that you like. After execution of the program, the MsgBox provides you with the message "My admission price is ??" (depending what age you submitted). Click OK.
EXERCISE 4 - AGE MACRO
For your own reference, you may sketch out a flowchart to help you to think about the logic used for this exercise. Do not submit the flowchart.
Type this code after the End Sub statement that is the last statement for the Sub Decision_Making macro (previous exercise).
Name this macro Age.
Referring to the above example, write out a program to ask the user whether their age is less than 6.
If so, you will pay 5 else you will pay 25.
Assign these pay amounts to the variable named "admission".
Run the program. When prompted for the age, enter either a value less than 6 or greater than 6. Click OK.
and the excercise 4 part is where I can't get it to work. I used the exercise about it as a model, but cant get it to work. here is what I have so far:
Sub age()
Dim age As conditionvalue
age = inputbox("are you younger than 6?")
If age = yes then
admission = 5
else
admission = 25
end if
msgbox("my admission price is $" & admission & "")
end sub
I'm not experienced in this stuff at all, and i think that the conditionvalue part may be wrong, but I just don't know what to put to change it from an integer to a yes/no answer. Any help would be much appreciated.
I am taking an intro to computers class as a pre-requisite for a geology, and currently we are working on automations or whatever its called for excel using visual basic for applications. I have finished most of my project, however I am stuck on the last part of it. the instructions are as follows:
Create another Macro named Decision_Making.
The following code translates the flowchart information into an actual program. Type the following code after your last exercise displayed in the Code window of the Visual Basic Screen.
Sub Decision_Making
Dim age As Integer
age = InputBox("My age is")
If age > 18 Then
admission = 18
Else
admission = 10
End If
MsgBox ("My admission price is $" & admission & "")
End Sub
Execute the program by pressing F5. Enter any values that you like. After execution of the program, the MsgBox provides you with the message "My admission price is ??" (depending what age you submitted). Click OK.
EXERCISE 4 - AGE MACRO
For your own reference, you may sketch out a flowchart to help you to think about the logic used for this exercise. Do not submit the flowchart.
Type this code after the End Sub statement that is the last statement for the Sub Decision_Making macro (previous exercise).
Name this macro Age.
Referring to the above example, write out a program to ask the user whether their age is less than 6.
If so, you will pay 5 else you will pay 25.
Assign these pay amounts to the variable named "admission".
Run the program. When prompted for the age, enter either a value less than 6 or greater than 6. Click OK.
and the excercise 4 part is where I can't get it to work. I used the exercise about it as a model, but cant get it to work. here is what I have so far:
Sub age()
Dim age As conditionvalue
age = inputbox("are you younger than 6?")
If age = yes then
admission = 5
else
admission = 25
end if
msgbox("my admission price is $" & admission & "")
end sub
I'm not experienced in this stuff at all, and i think that the conditionvalue part may be wrong, but I just don't know what to put to change it from an integer to a yes/no answer. Any help would be much appreciated.