Help with Interface/Msgbox in VBA


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.


You can use 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


Thanks to venkat1926 for this tip on the forum.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
This document, titled « Help with Interface/Msgbox in VBA », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (