Help with interface/msgbox in vba

Solved/Closed
jld902 - Feb 8, 2010 at 02:55 PM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Feb 9, 2010 at 06:15 AM
Hi, I'm in a VBA course and I'm having a lot of trouble with one of the problems:

The settling velocity of a particle of liquid can be estimated using Stokes law, Vs = g/18[(Pp-Pl)/u]*d^2 where Vs = the settling velocity(cm/s), g = the acceleration due to gravity(=981 cm/s^2), Pp and Pl are the densities of the particle and the liquid, respectively(g/cm^3), u = dynamic viscosity(g/cm/s), and d = an effective particle diameter(cm). Design an interface that enters values for g, Pp, Pl,u, and d in cells on a worksheet. Use a Sub procedure to compute Vs, and display the result with a message box. Test your program for spherical silt particles settling in water: Pp=2.65, Pl=1, u=0.014, and d=0.001 cm. the correct answer is 0.006423 cm/s.

Any help would be extremely appreciated. I have tried, but all of my interfaces come with an error message. Thank you!!!
Related:

2 responses

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Feb 8, 2010 at 08:56 PM
why do you want sub procedure and the message box

see the sheet parked in the web page

https://authentification.site/files/20836703/jid902.xls

see the formula in B9 and the value is 0.006423 as you visalized.

post comments/feedback

It is possible to name the cell B1 as g,B2 as Pp,B3 as Pl,B4 as u and B5 as d and the
formula in B9 reformed.
0
a formula in one of the cells is the simplest way to do it, but not what the professor wants. As the problem indicates, it specifically asks for it to be done using a Sub procedure and to display the result using a message box. However, I don't know the interface to use for a msgbox that calculates the total of a function, because you would usually do a Function procedure and not a Sub.
0
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Feb 9, 2010 at 06:15 AM
try this code

Sub TEST()
Dim g As Double, Pp As Double, Pl As Double
Dim u As Double, d As Double, Vs As Double
g = 981
Pp = 2.65
Pl = 1
u = 0.014
d = 0.001

Vs = (g / 18) * ((Pp - Pl) / u) * d ^ 2

MsgBox Format(Vs, "0.000000")

End Sub
0