Hi guys and girls, I am working on a project and have become a little lost.
could somebody please tell me how to program a solve button, also my program is not giving the correct values for tw or hw can anyone spot an error..
thanks
here is the question
![Name: q2 pic.png
Views: 92
Size: 96.5 KB]()
and here is the code
could somebody please tell me how to program a solve button, also my program is not giving the correct values for tw or hw can anyone spot an error..
thanks
here is the question
and here is the code
Code:
Imports System.Math 'This line is required for Math functions
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
End Sub
Private Sub Label7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles input_data.Click
End Sub
Private Sub Label11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles results.Click
End Sub
Private Sub TextBox20_TextChanged(sender As Object, e As EventArgs) Handles TextBox20.TextChanged
' The time of flight of the stone to reach the wall, tw, can be calculated by.............. tw=L/V0*cos(theta)
Dim tw, L, v0 As Integer
'Declaration
Dim d, Cos(d) As Double
Dim numerator, denominator, n As Integer
'Usage
Dim returnValue As Double
returnValue = Math.Cos(d)
For i = 0 To n - 1
numerator = L
denominator = v0 * returnValue
tw = numerator / denominator
'Retrieve v0 and L
L = CDbl(Val(TextBox17.Text))
v0 = CDbl(Val(TextBox15.Text))
Next
End Sub
Private Sub TextBox17_TextChanged(sender As Object, e As EventArgs) Handles TextBox17.TextChanged
End Sub
Private Sub TextBox15_TextChanged(sender As Object, e As EventArgs) Handles TextBox15.TextChanged
End Sub
Private Sub TextBox21_TextChanged(sender As Object, e As EventArgs) Handles TextBox21.TextChanged
Dim hw, v0, h1, tw, w, h2 As Double
Dim d, Sin(d) As Double
Const g As Double = 9.806
'Usage
Dim returnValue As Double
returnValue = Math.Sin(d)
tw = CDbl(Val(TextBox20.Text))
w = CDbl(Val(TextBox24.Text))
hw = -0.5 * g * tw ^ 2 + (v0 * Sin(d)) * tw + h1
End Sub
Private Sub hits_the_wall_Click(sender As Object, e As EventArgs) Handles hits_the_wall.Click
End Sub
Private Sub TextBox24_TextChanged(sender As Object, e As EventArgs) Handles TextBox24.TextChanged
End Sub
Private Sub TextBox22_TextChanged(sender As Object, e As EventArgs) Handles TextBox22.TextChanged
Dim hw, w, h2 As Double
hw = CDbl(Val(TextBox21.Text))
w = CDbl(Val(TextBox24.Text))
h2 = CDbl(Val(TextBox25.Text))
If h2 < hw And hw < h2 + w Then
Console.WriteLine("attempt successful")
Else
Console.WriteLine("attempt was not successful")
End If
End Sub
Private Sub solve_Click(sender As Object, e As EventArgs) Handles solve.Click
End Sub
Private Sub TextBox25_TextChanged(sender As Object, e As EventArgs) Handles TextBox25.TextChanged
End Sub
End Class