×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

(OP)
I have written a program that is math intensive. What I want to do is be able to run an interate to a sample situation. The sample would be something like this. Calculate the speed of a vehicle that left 30 feet of skid marks on a road that has a .7 to .85 friction factor. The initial calculation would be the Sqr(30*D*F) The D would be the distance the vehicle skidded and the F would be the friction factor. What I want to do is take the low friction factor of .7 and then in increments of .01 go up to .85 and display the results of that query in the selected series. I would also like to display the f value that was used for each speed result to the right of each result. That way the user could identify what f value was used for each particular speed calculation. It would be something like this.
34.3 Mph .7 f
34.6 Mph .71f
35.0 Mph .72f
Up to .85f Value which would be the maximum value.

Any assistance would be greatly appreciated. Thank you in advance for your help. Please make the explaination easy as I am still learning. Thank you.

Hi beck

Here is a simple little Sub to get you started

Sub CalcSpeed(sngStart As Single, sngStop As Single, sngStep As Single, sngDistance As Single)
Dim sngFricFact As Single

Cls
For sngFricFact = sngStart To sngStop Step sngStep
Print Format$(Sqr(30 * sngFricFact * sngDistance), "##0.0") & _ "MPH <=> " & Format$(sngDistance, "###") & _
"ft Distance & " & Format\$(sngFricFact, "0.00") & " Friction Factor"
Next
End Sub

You would call it as follows (for the numbers used in your example):

CalcSpeed .7,.85,.01,30

or you could pass numeric variables Dim'ed as Single to it, e.g.

CalcSpeed FricStart!, FricEnd!, .01, Distance!

You can improve on this Sub (and make it more usable) by storing the results in an array for later use or by turning it into a function which returns the result of a single calculation. This could then be called from a loop, etc.

Hope this helps
-Ian

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!