[RESOLVED] Picture box with text help please

Need the skill of the pros here on this one. I have on my form a Command button, 4 textboxes and 2 picture boxs. I am try to get the program to figure out this equation, print the results in Picture1 and make a graph in Picture2.
It starts out with Picture1 by printing the titles but will not show any answers from the equation and Picture2 does nothing at all.

Any help with this is greatly appreciated. Thanks ~ Probie.

Option Explicit
Dim velArray(21) As Single 'initial velocity array

Private Sub Command1_Click()
Dim a As Single, b As Integer, Mu As Single, D As Single
Dim x As Integer, y As Single, z As Single, t As Single, acc As Single
Dim i As Integer, Vc As Single, Dist0 As Single
Dim ft As Integer
Const g = 32.2
Mu = Text1.Text 'coefficient of kinetic energy friction (0<Mu=<1)
acc = Text2.Text ' acceleration/deceleration in ft/sec^2. acc <0
Vc = Text3.Text ' Vc: Velocity of front of car in m/ph
Dist0 = Text4.Text 'Dist0: distance between two cars in ft


'Draw the x y axis
Picture2.DrawWidth = 2
Picture2.Scale (0, 400)-(500, 0) 'Set scale
Picture2.Line (0, 0)-(400, 0) 'Draw the x y axis
Picture2.Line (0, 0)-(0, 4000)

'Opening input and output files
Open "C:\Windows\Desktop\HW\initialvelocities.txt" For Input As #1
Open "C:\Windows\Desktop\HW\stoppingdistances.txt" For Output As #2

Picture1.Print "Initial Velocity", " Stopping", "Stopping", "Collision",
Picture1.Print "Vo (m/ph)", "Distance", "Time t(s)", "Range",
Picture1.Print "", " D (ft) "
'Picture1.Print "___________", "__________", "_________", "__________",

Print #2, "Initial Velocity", "Stopping", "Stopping", "Collision",
Print #2, "Velocity", "Distance", "Time ", "Range",
Print #2, "Vo (m/ph)", "D(ft)", "t (s)"
Print #2, "___________", "__________", "_________", "__________",

Do While Not (EOF(1))

For i = 1 To 21
Input #1, velArray(i) 'reading file into array
a = velArray(i)
D = ((a * (3600 / 5280)) ^ 2) / (2 * Mu * g) 'evaluating stopping distance
t = a * (3600 / 5280) / acc 'evaluating stopping time

For x = 0 To velArray(i) 'Plot stopping velocity vs stopping distance
y = ((x * (3600 / 5280)) ^ 2) / (2 * Mu * g)
z = x * (3600 / 5280) / acc
Picture2.PSet (x, y), RGB(225, 0, 0)
Picture2.PSet (x, z), RGB(13, 170, 4)
Next x

If (Vc * t + Dist0) <= D Then 'Checking for collision
Picture1.Print a, D, t; "YES" 'Print veh velocity and corresponding stopping distance
Print #2, a, D, t, "YES" 'Print table to an output file
Else
If (Vc * t + Dist0) >= D Then
Picture1.Print a, D, t, "NO" 'Print veh velocity and corresponding stopping distance
Print #2, a, D, t, "NO" 'Print table to an output file

End If
End If
Next i
Loop
Close #1

End Sub
[4055 byte] By [Probie] at [2007-11-20 10:53:32]
# 1 Re: [RESOLVED] Picture box with text help please
Sorry, we don't do homework around here. Spend a few minutes, press F8, and see what happens. Press F8 enough times, and you will see exactly what your program does, and how.
Then run it again.

You'll see that you can probably use all of the code that you were given, if you change or repeat a few things.

Post back if you run into problems. Hope it isn't due tomorrow!
dglienna at 2007-11-9 19:34:21 >
# 2 Re: [RESOLVED] Picture box with text help please
dglienna, I hate to have to inform you of this... but this is not homework...I am 50 years old. This is a program am I am trying to write that deals with accident reconstruction. I figured I would try to introduce some graphics to the program rather then just a bunch of text boxes that introduce the answer to the user.
Probie at 2007-11-9 19:35:16 >
# 3 Re: [RESOLVED] Picture box with text help please
Sorry. You'd be surprised to see how many people ask for homework help.

For the totals, you need an accumulator for each field. It looks like you could just use the graphics code.

Post the whole project (or this part) so I can test something, and I'll take a look.
dglienna at 2007-11-9 19:36:14 >
# 4 Re: [RESOLVED] Picture box with text help please
The easy answer first. Ensure your pictureboxes AutoRedraw=True and that you Refresh the pictureboxes after done drawing.
LaVolpe at 2007-11-9 19:37:15 >
# 5 Re: [RESOLVED] Picture box with text help please
No need to apologize, dglienna. I can see where this would be a benifit to those who do not like to do homework.
My AutoDraw is set to true.
Here is the code for this form....I do not see a place on this site to upload a zip file or I would zip this section and send it to you. Cancel that I found the attachment button. The attachment contains the form I am trying to work on.

Option Explicit
Dim velArray(21) As Single 'initial velocity array

Private Sub cmdFormula_Click()
velCode.Show 'This form is just a velocity formula
Beep
End Sub

Private Sub Command1_Click()
Dim a As Single, b As Integer, Mu As Single, D As Single
Dim x As Integer, y As Single, z As Single, t As Single, acc As Single
Dim i As Integer, Vc As Single, Dist0 As Single
'Dim ft As Integer
Const g = 32.2
Mu = Text1.Text 'coefficient of kinetic energy friction (0<Mu=<1)
acc = Text2.Text ' acceleration/deceleration in ft/sec^2. acc <0
Vc = Text3.Text ' Vc: Velocity of front of car in m/ph
Dist0 = Text4.Text 'Dist0: distance between two cars in ft


'Draw the x y axis
Picture2.DrawWidth = 2
Picture2.Scale (0, 400)-(500, 0) 'Set scale
Picture2.Line (0, 0)-(400, 0) 'Draw the x y axis
Picture2.Line (0, 0)-(0, 4000)

'Opening input and output files
Open "C:\Windows\Desktop\HW\initialvelocities.txt" For Input As #1
Open "C:\Windows\Desktop\HW\stoppingdistances.txt" For Output As #2

Picture1.Print "Initial Velocity", " Stopping", "Stopping", "Collision"
Picture1.Print "Vo (m/ph)", " Distance", "Time t(s)", "Range"
Picture1.Print "", " D (ft) "
Picture1.Print "__________", "__________", "________", "_______",

Print #2, "Initial ", "Stopping", "Stopping", "Collision"
Print #2, "Velocity", "Distance", "Time ", "Range"
Print #2, "Vo (m/ph)", "D(ft)", "t (s)"
Print #2, "________", "________", "_________", "__________",

Do While Not (EOF(1))

For i = 1 To 21
Input #1, velArray(i) 'reading file into array
a = velArray(i)
D = ((a * (3600 / 5280)) ^ 2) / (2 * Mu * g) 'evaluating stopping distance"
t = a * (3600 / 5280) / acc 'evaluating stopping time

For x = 0 To velArray(i) 'Plot stopping velocity vs stopping distance
y = ((x * (3600 / 5280)) ^ 2) / (2 * Mu * g)
z = x * (3600 / 5280) / acc
Picture2.PSet (x, y), RGB(225, 0, 0)
Picture2.PSet (x, z), RGB(13, 170, 4)
Next x

If (Vc * t + Dist0) <= D Then 'Checking for collision
Picture1.Print a, D, t, "YES" 'Print veh velocity and corresponding stopping distance
Print #2, a, D, t, "YES" 'Print table to an output file
Else
If (Vc * t + Dist0) >= D Then
Picture1.Print a, D, t, "NO" 'Print veh velocity and corresponding stopping distance
Print #2, a, D, t, "NO" 'Print table to an output file

End If
End If
Next i
Loop
Close #1

End Sub
Probie at 2007-11-9 19:38:25 >
# 6 Re: [RESOLVED] Picture box with text help please
You can scroll down to the MANAGE ATTACHMENTS checkbox, and then upload the file. Make sure that it's zipped, and that it's attached. Then we can download it. We need some sample data as well. Include the text files
dglienna at 2007-11-9 19:39:18 >
# 7 Re: [RESOLVED] Picture box with text help please
Found it, and added to the prev. post.....thanks.
Probie at 2007-11-9 19:40:22 >
# 8 Re: [RESOLVED] Picture box with text help please
Change these two lines for the future, and copy the files there:

Open App.Path & "\initialvelocities.txt" For Input As #1
Open App.Path & "\stoppingdistances.txt" For Output As #2

the file you included in 0 length, and can't get thru the loop for me to test.

don't you have valid data in the file?

Your program reads 21 samples, and plots from there.
dglienna at 2007-11-9 19:41:26 >
# 9 Re: [RESOLVED] Picture box with text help please
here. i made one up.

100
200
300
400
500
600
700
750
800
850
900
950
1000
1100
1200
1300
1400
1500
1600
1700
1800

not a pretty graph, but it plots fine
dglienna at 2007-11-9 19:42:21 >
# 10 Re: [RESOLVED] Picture box with text help please
dglienna, you have to be the smartest person I have ever met. You amaze me with your programming abilities.
I may not be very bright when it comes to programming, but I may be able to help you if you ever get stuck on physics.
The graph may not be pretty...but with my limited talent with programming, I will take it.
Thanks very much...you are the best and I mean that. ~Probie
Probie at 2007-11-9 19:43:21 >
# 11 Re: [RESOLVED] Picture box with text help please
Thanks. I usually turned in such assgnments. :)

Don't forget to mark it as resolved.
dglienna at 2007-11-9 19:44:26 >