Exam 4 -VBA
Supplemental Instruction
IowaStateUniversity / Leader: / Becca
Course: / ChE 160
Instructor: / HeinenHaman
Date: / 12/04/2016
Resources
- VBA chapters on Blackboard. HINT: Download for future reference!
- Youtube channels such as WiseOwlTutorials
- ByRef/ByVal explanation:
Study strategies
- Really understand the basics and go from there
- Look at the SI worksheets posted
- Redraw graphs and figures
- Rewrite notes
- Reword ideas and principles
- Write out steps to problem solving
- Talk about notes and concepts with a friend
- Make your own example problems
- Write a reference sheet with all study information to review right before
Notes from Becca
- Read through Exam 4 information on Blackboard
- You should be able to finish the entire exam in 50 min
- Strategize—start with the easy problems first to knock them out or hard problems first
- If you don’t know, skip it and come back
- Show your work! Partial credit is better than no credit
PRACTICE EXAM (Note: adapted from Dr. Heinen’s practice exam format.)
State the value of the variable that result from each of the VBA commands. Do you understand the logic of loops? Try saying loops in full sentences.
T = 8T =
Do
If (T <= 87) Then
T = T*2
ElseIf (T= 87) Then
T = T^0.5
Else Exit Do
End If
Loop
z(1,1) = 20 z =
For count = 2 To 4
z(1,count) = z(1,count-1) / 2
Next count
Sub SI_Is_Awesome()a =
b =
Dim a As Single, b As Integer, c As Singlec =
a = 5
b = 12.5
c = difference(a,b)
End Sub
Function difference(ByVal a As Integer, ByRef b As Single)
a = 25
b = b*2
difference = a-b
End Function
Short Answer
Write the command that requires all variables to be declared by type.
What are the four data types addressed in ChE 160 VBA Unit?
Problem Solving
Write a loop that calculates the factorial of whole, even numbers from 2 to 10, and then displays the results with a message box. Which loop would be best for this type of problem? How do you know?
Reynolds Number
The Reynolds number is a dimensionless quantity to predict fluid flow patterns such as laminar and turbulent. (You will learn all about this in ChE 356!)
where v = superficial velocity [m/s]
(rho) = density [kg/m3]
L = characteristic length [m]
(mu) = dynamic viscosity of fluid [kg/ms]
In a pipe, laminar flow occurs when Re < 2300; transient flow occurs when 2300 < Re < 4000; turbulent flow when Re > 4000.
Write a function that calculates the Reynolds number for given velocity, density, length, and viscosity values. Don’t forget about ByRef and ByVal. What is the difference between them?
Reynolds Number (cont’d.)
In a sub-procedure, use input boxes to ask the user for superficial velocity, density, characteristic length, and dynamic viscosity. Calculate the Reynolds number using the function you just wrote and save the value as ReNum. Use a message box to display whether the flow is laminar, transient, or turbulent based on the Reynolds number. Do you need a loop? If so, which loop would be best?
Heat Exchanger Data
The temperature data shown below is contained in the file X:\Desktop\Tdata.txt, and is from your work in ChE 325 lab with shell-and-tube heat exchangers. Input the data into a VBA matrix, and then export the data to a new file, X:\Desktop\HeatExchT.txt, that can be read by VBA. Which form of outputting information can be read by VBA?
T_cold,in [C] / T_cold,out [C]11.2 / 35.3
11.1 / 32.8
10.9 / 31.7
10.8 / 28.7
10.7 / 26.3
10.7 / 26.1
A 7.1 m^3 cylindrical tank rated to a pressure of 15.7*10^5 Pa contains 1500 moles of gas. Use a Do loop to calculate the maximum temperature that the gas in the tank can reach before exceeding the pressure rating. Begin at 273 K and work in 5 K increments. R = 8.314 Pa m^3/mol K. Use a message box to display “The maximum temperature before exceeding the pressure rating is ______K.”What should be inside the Do loop? What values/variables do you have to initialize before?
What topics should you spend more time studying?
Are there any study strategies that have worked well for you?
GOOD LUCK! YOU WILL DO GREAT!