Novice learning how to use Visual Basic 6.0, having trouble making a triangle angle calculator.

Okay so this is the code. Starting with muh variables.

Dim Angle1 As Double
Dim Angle2 As Double
Dim Angle3 As Double

This is my Triangle button, it sees if the angles put in three text boxes add up to 180, and if it does then it confirms it is a triangle.

Private Sub Calculate_Click()
Angle1 = Val(Angle1)
Angle2 = Val(Angle2)
Angle3 = Val(Angle3)

If Angle1 + Angle2 + Angle3 = 180 Then
Check1 = 1
End If
If Angle1 = 0 Or Angle2 = 0 Or Angle3 = 0 Then
Check3 = 1
End If
If Angle1 < 0 Then                                                                 
Check3 = 1
End If
If Angle2 < 0 Then
Check3 = 1
End If
If Angle3 < 0 Then
Check3 = 1
End If
End Sub

Clear Button

Private Sub Command1_Click()
Text1.Text = " "
Text2.Text = " "
Text3.Text = " "
Check1 = 0
Check2 = 0
Check3 = 0

End Sub

The Right Triangle Button, sees if the triangle is a right triangle.

Private Sub RightTriangleCalc_Click()
Angle1 = Val(Angle1)
Angle2 = Val(Angle2)
Angle3 = Val(Angle3)


If Angle1 Or Angle2 Or Angle3 < 0 Then
Check2 = 0
End If

If (Angle1 = 90 And Angle1 + Angle2 + Angle3 = 180) Or (Angle2 = 90 And Angle1 + Angle2 + Angle3 = 180) Or (Angle3 = 90 And Angle1 + Angle2 + Angle3 = 180) Then
Check2 = 1
ElseIf Angle1 + Angle2 + Angle3 = 180 Then
Check2 = 1
End If
If Angle1 < 0 Or Angle2 < 0 Or Angle3 < 0 Then
Check2 = 0
End If

End Sub

Okay so I have 3 check boxes, and these check boxes tell if the angles sum up to be a triangle, a right triangle, or not a triangle. the first check box confirms that the numbers add up to a triangle. The second check box confirms it is a right triangle. The third check box confirms it is not a triangle. So I don't know what, or why, but whenever i click either button it automatically checks the third button ( not triangle), even when the angles add up to 180.

Okay and also, i'm a complete noob at visual basic 6.0 ( 10th grader touching the program for the second time). If you have any tips on making my code better then go ahead, be critical too idc. Thanks

Posted Feb 17, 2017, 2:38 AM UTC · edited

22
Loading comments…