1,105,578 Community Members

Cannot get list box to display each increment and cannot get data to save correctly

Member Avatar
whitetigerz79
Newbie Poster
4 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Attachments Mundy_Projectile_Motion.zip (83.52KB)
Member Avatar
whitetigerz79
Newbie Poster
4 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Sorry this should be more readable!!

Public Class Projectile_Motion
    Dim initialHeight As Double ' Holds beginning height
    Dim initialVelocity As Double ' holds velocity
    Dim time As Double ' holds time
    Dim heightVal As Double ' holds height at different intrvals in time

    Private Sub btnmaxheight_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmaxheight.Click
        'Performs the calculation to determine the maximum height based on the initial velocity

        time = CInt(initialVelocity / 32)
        heightVal = initialHeight + time * initialVelocity - 16 * Math.Pow(time, 2)

        Lstresults.Items.Add("Maximum height equals " & Math.Round(heightVal, 2) & " feet.")
    End Sub

    Private Sub btnApproxTime_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnApproxTime.Click

        heightVal = initialHeight
        time = 0
        While heightVal > 0
            time += 1
            heightVal = initialHeight + time * initialVelocity - 16 * Math.Pow(time, 2)

        End While
        Lstresults.Items.Add("Approximate time until the ball will hit the ground - " & Math.Round(time, 2) & " seconds.")
    End Sub



    Private Sub btnDisplayTable_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplayTable.Click
        Lstresults.Items.Add(vbTab & "Time" & vbTab & "Height")
        Dim t As Double
        For t = 0.0 To 5.0 Step 0.25
            heightVal = initialHeight + t * initialVelocity - 16 * Math.Pow(t, 2)
            If heightVal < 0 Then
         Exit For
            Else
                Lstresults.Items.Add(vbTab & FormatNumber(t, 2) & vbTab & FormatNumber(heightVal, 1))

            End If
        Next
    End Sub

    Private Sub txtheight_leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtheight.Leave
        'Displays an error message if the input isn't numeric
        If Not IsNumeric(txtheight.Text) Then
            MsgBox("Please input only numbers!")
            txtheight.Clear()
            txtheight.Focus()
        End If
    End Sub

    Private Sub txtVelocity_leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtVelocity.Leave
        'Displays an error message if the input isn't numeric
        If Not IsNumeric(txtVelocity.Text) Then
            MsgBox("Please input only numbers!")
            txtVelocity.Clear()
            txtVelocity.Focus()
        End If
    End Sub

    Private Sub btnQuit_Click(sender As System.Object, e As System.EventArgs) Handles btnQuit.Click
        Me.Close()
    End Sub



End Class
Member Avatar
whitetigerz79
Newbie Poster
4 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I got IT!!
[

Public Class Projectile_Motion
    Dim startVelocity, startHeight, heightVal, time As Double

    Private Sub btnmaxheight_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmaxheight.Click
        'Performs the calculation to determine the maximum height based on the initial velocity
        startVelocity = txtVelocity.Text
        startHeight = txtheight.Text
        time = CInt(startVelocity / 32)
        heightVal = startHeight + time * startVelocity - 16 * Math.Pow(time, 2)

        Lstresults.Items.Add("Maximum height equals " & Math.Round(heightVal, 2) & " feet.")
    End Sub

    Private Sub btnApproxTime_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnApproxTime.Click
        startVelocity = txtVelocity.Text
        startHeight = txtheight.Text
        heightVal = startHeight
        time = 0
        While heightVal > 0
            time += 1
            heightVal = startHeight + time * startVelocity - 16 * Math.Pow(time, 2)

        End While
        Lstresults.Items.Add("Approximate time until the ball will hit the ground - " & Math.Round(time, 2) & " seconds.")
    End Sub



    Private Sub btnDisplayTable_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplayTable.Click
        Lstresults.Items.Add(vbTab & "Time" & vbTab & "Height")
        startVelocity = txtVelocity.Text
        startHeight = txtheight.Text
        Dim t As Double
        For t = 0.0 To 5.0 Step 0.25
            heightVal = startHeight + t * startVelocity - 16 * Math.Pow(t, 2)
            If heightVal < 0 Then
                Exit For
            Else
                Lstresults.Items.Add(vbTab & FormatNumber(t, 2) & vbTab & FormatNumber(heightVal, 1))

            End If
        Next
    End Sub

    Private Sub txtheight_leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtheight.Leave
        'Displays an error message if the input isn't numeric
        startHeight = txtheight.Text
        If Not IsNumeric(txtheight.Text) Then
            MsgBox("Please input only numbers!")
            txtheight.Clear()
            txtheight.Focus()
        End If
    End Sub

    Private Sub txtVelocity_leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtVelocity.Leave
        'Displays an error message if the input isn't numeric
        startVelocity = txtVelocity.Text
        If Not IsNumeric(txtVelocity.Text) Then
            MsgBox("Please input only numbers!")
            txtVelocity.Clear()
            txtVelocity.Focus()
        End If
    End Sub

    Private Sub btnQuit_Click(sender As System.Object, e As System.EventArgs) Handles btnQuit.Click
        Me.Close()
    End Sub

End Class
Member Avatar
kingsonprisonic
Posting Whiz in Training
265 posts since Nov 2009
Reputation Points: 42 [?]
Q&As Helped to Solve: 54 [?]
Skill Endorsements: 0 [?]
 
0
 

I got IT!!

Will your problem solved??? or you have any error?

Member Avatar
whitetigerz79
Newbie Poster
4 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Will your problem solved??? or you have any error?

I solved it. Thank you...it was so simple!! I don't know how I wasn't able to do it sooner

Member Avatar
kingsonprisonic
Posting Whiz in Training
265 posts since Nov 2009
Reputation Points: 42 [?]
Q&As Helped to Solve: 54 [?]
Skill Endorsements: 0 [?]
 
0
 

ok then mark this thread as solved.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: