Public Class Projectile_Motion
02 Dim initialHeight As Double ' Holds beginning height
03 Dim initialVelocity As Double ' holds velocity
04 Dim time As Double ' holds time
05 Dim heightVal As Double ' holds height at different intrvals in time
06
07 Private Sub btnmaxheight_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmaxheight.Click
08 'Performs the calculation to determine the maximum height based on the initial velocity
09
10 time = CInt(initialVelocity / 32)
11 heightVal = initialHeight + time * initialVelocity - 16 * Math.Pow(time, 2)
12
13 Lstresults.Items.Add("Maximum height equals " & Math.Round(heightVal, 2) & " feet.")
14 End Sub
15
16 Private Sub btnApproxTime_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnApproxTime.Click
17
18 heightVal = initialHeight
19 time = 0
20 While heightVal > 0
21 time += 1
22 heightVal = initialHeight + time * initialVelocity - 16 * Math.Pow(time, 2)
23
24 End While
25 Lstresults.Items.Add("Approximate time until the ball will hit the ground - " & Math.Round(time, 2) & " seconds.")
26 End Sub
27
28
29
30 Private Sub btnDisplayTable_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplayTable.Click
31 Lstresults.Items.Add(vbTab & "Time" & vbTab & "Height")
32 Dim t As Double
33 For t = 0.0 To 5.0 Step 0.25
34 heightVal = initialHeight + t * initialVelocity - 16 * Math.Pow(t, 2)
35 If heightVal < 0 Then
36 Exit For
37 Else
38 Lstresults.Items.Add(vbTab & FormatNumber(t, 2) & vbTab & FormatNumber(heightVal, 1))
39
40 End If
41 Next
42 End Sub
43
44 Private Sub txtheight_leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtheight.Leave
45 'Displays an error message if the input isn't numeric
46 If Not IsNumeric(txtheight.Text) Then
47 MsgBox("Please input only numbers!")
48 txtheight.Clear()
49 txtheight.Focus()
50 End If
51 End Sub
52
53 Private Sub txtVelocity_leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtVelocity.Leave
54 'Displays an error message if the input isn't numeric
55 If Not IsNumeric(txtVelocity.Text) Then
56 MsgBox("Please input only numbers!")
57 txtVelocity.Clear()
58 txtVelocity.Focus()
59 End If
60 End Sub
61
62 Private Sub btnQuit_Click(sender As System.Object, e As System.EventArgs) Handles btnQuit.Click
63 Me.Close()
64 End Sub
65 End Class
whitetigerz79
0
Newbie Poster
Recommended Answers
Jump to PostI got IT!!
Will your problem solved??? or you have any error?
Jump to Postok then mark this thread as solved.
All 5 Replies
whitetigerz79
0
Newbie Poster
whitetigerz79
0
Newbie Poster
kingsonprisonic
42
Posting Whiz in Training
whitetigerz79
0
Newbie Poster
kingsonprisonic
42
Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.