PDA

View Full Version : Old Visual Basic code



david blaine
03-22-2008, 12:27 PM
I guess it will help somebody? idc

date Thu, Jan 5, 2006 at 2:29 PM



Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
Dim a, b, c As Double
a = InputBox("What is the a value?", "A:")
b = InputBox("What is the b value?", "B:")
c = InputBox("What is the c value?", "C:")
Quadratic(a, b, c)
End Sub
Sub Quadratic(ByRef a As Double, ByRef b As Double, ByRef c As Double)
'Determine how many real solutions
If (a = 0) Then
MsgBox("A cannot equal zero")
Else
a = a
End If
If b ^ 2 - (4 * a * c) > 0 Then
txtType.Text = "2 Real Roots"
ElseIf b ^ 2 - (4 * a * c) = 0 Then
txtType.Text = "1 Real Root"
Else
txtType.Text = "0 Roots"
End If
'Now we find the solutions
txtQuad.Text = CStr("The Roots are " & (QuadNeg(a, b, c) & " and " & QuadPos(a, b, c)))
End Sub
Function QuadNeg(ByRef a As Double, ByRef b As Double, ByRef c As Double)
Return (-b - Math.Sqrt(b ^ 2 - 4 * a * c)) / (2 * a)
End Function
Function QuadPos(ByRef a As Double, ByRef b As Double, ByRef c As Double)
Return (-b + Math.Sqrt(b ^ 2 - 4 * a * c)) / (2 * a)
End Function

david blaine
03-22-2008, 12:32 PM
moar

Private Sub vF_Scroll_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles vF.Scroll

If vF.Value <= 33 Then

vC.Value = 5

Else

vC.Value = ((vF.Value - 32) * (5 / 9))

txtC.Text = vC.Value & "&#176;"

txtF.Text = vF.Value & "&#176;"

End If

End Sub



Private Sub vC_Scroll_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles vC.Scroll

vF.Value = ((9 / 5) * vC.Value) + 32

txtC.Text = vC.Value & "&#176;"

txtF.Text = vF.Value & "&#176;"

End Sub



Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

vF.Maximum = 212

vC.Maximum = 100

End Sub