Hello,
Im new to VB and therefore i require some guidance in this tricky situation that im stuck in.
Basically, what my program does is calculate the mach number of an aircraft when the speed of sound and value of temperature are added into the text box. The problem arises in 2 places. One, the program calculates the value of speed wrongly. And secondly (The major part) is that i want the program to display an error that i should enter both the values (that is, if only one value is entered and calculate button is pressed.)and if i enter any alphabets, it should give an error to please input numbers.
Ill be really greatful if anyone can help me out on this. Thanks.
Here's the code.
Public Class mach
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim t As Double
Dim v As Double
t = CDbl(TextBox1.Text)
v = CDbl(TextBox2.Text)
Dim R As Integer = 287
Dim Gamma As Integer = 1.4
Dim x As Double = 287 * 1.4 * t
Dim speed As Double = Math.Sqrt(x)
Dim mach As Double = v / speed
If TextBox1.Text <= 270 Then
MsgBox("Flight in these conditions is impossible. Please enter the value of Temperature Greater than 270K")
ElseIf mach <= 0.3 Then
TextBox3.Text = speed
TextBox4.Text = mach
TextBox5.Text = "The Flight is Incompressible and Subsonic"
ElseIf mach > 0.3 And mach <= 1 Then
TextBox3.Text = speed
TextBox4.Text = mach
TextBox5.Text = "The Flight is Compressible and Subsonic"
ElseIf mach > 1 And mach <= 5 Then
TextBox3.Text = speed
TextBox4.Text = mach
TextBox5.Text = "The Flight is Supersonic"
ElseIf mach > 5 Then
TextBox3.Text = speed
TextBox4.Text = mach
TextBox5.Text = "The Flight is Hypersonic"
Exit Sub
End If
End Sub
End Class