Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Calculations

Status
Not open for further replies.

beck

Programmer
Mar 22, 1999
26
0
0
US
I am attempting to write a loop or some other form of code which will allow me to perform multiple calculations based on basic entires along with a range variable. An example would be the following. <br>The user would have the following screen:<br>SPEED FROM SKID MARKS<br>Enter Distance vehicle Skidded: 75<br>Enter Road Surface Friction: From:.75 to:.85<br>Enter Increment for road surface Friction:.01<br>The Calculation in current use is the following. <br>d = Text1.text&nbsp;&nbsp;(Represents Distance)<br>f = Text2.text&nbsp;&nbsp;(Represents first Friction)<br>f1 = Text3.text (Represents Second Friction)<br>I have nothing for the increment section<br>Label7.Caption = Format(Sqr(30*d*f),&quot;##0.00&quot;)&&quot;Mph&quot;<br>Label16.Caption=Format(Sqr(30*d*f1),&quot;##0.00)&&quot;Mph&quot;<br><br>Thus the results are displaded in the various labels assigned above. What I want to do is have the program start with the from :.75 and then based on the increments assigned by the user work from the .75 to .85 and provide the results to the screen. Can this be done? How do I display the results to the user on a particular space on the form once variables are assigned. I am using Visual Basic 6 Pro to write this program. <br>What I am hoping for is that the results will be displayed something simular to the following. <br><br>.75 = 25.2 Mph<br>.76 = 25.8 Mph<br>.77 = 26.3 Mph<br>etc. This assumes a variable of .01 was entered. The results above are not assumed to be correct and only listed as an example. <br>Any assistance would be greatly appreciated. I am very new at writing this code so if you can be as explicite as possible, I would appreciate it. Thank you in advance for your assistance.<br> <p> <br><a href=mailto:accrec@intergrafix.net>accrec@intergrafix.net</a><br><a href= > </a><br>
 
Hi Beck,<br><br>There are two problems here, so let's take them one at at time:<br><br>1 - the calculations<br><br>This one is easy - you just have a for loop.<br><br>For i = f To f1 Step Incr ' Incr is your increment variable<br>&nbsp;&nbsp;&nbsp;&nbsp;Label7.Caption = Format(Sqr(30*d*i),&quot;##0.00&quot;)&&quot;Mph&quot;<br>Next i<br><br>but that puts all your answers in the one label....<br><br>2 - display<br><br>Not quite so easy but not too bad<br><br>instead of having just the one label have a control array of labels, then you can say....<br><br>dim x as integer<br>x=0<br>For i = f To f1 Step Incr ' Incr is your increment variable<br>&nbsp;&nbsp;&nbsp;&nbsp;Label7(x).Caption = Format(Sqr(30*d*i),&quot;##0.00&quot;)&&quot;Mph&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;x=x+1<br>Next i<br><br>you do have to make sure that the number of steps between f and f1 doesn't exceed the nmber of labels <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top