RE: Calculator Help 05-25-2014, 11:32 PM
#11
Code:
Public Class geometry
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Form1.Show()
Me.Hide()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
RichTextBox1.Text = ("A square is a four-sided (quadrilateral) polygon of congruent side and angle measure. This means that each side length is the same and each angle is 90°. A Square is a type of parallelogram. a = s² p = 4(s)")
End Sub
Private Sub sqarea_TextChanged(sender As Object, e As EventArgs) Handles sqarea.TextChanged
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim area As Single
Dim length As Single
If sqlth.Text = "" Then
sqlth.Text = "0"
End If
If Not sqarea.Text Is DBNull.Value Then
sqarea.Text = "0"
End If
If Not IsNumeric(sqlth.Text) Then
sqlth.Text = "0"
RichTextBox1.Text = ("Error 1: Input was not a number. Strings such as 'apple', 'banana', 'x', or 'y' will trigger this error. Instead try and use a postive real number like '20', '310', or '20.5'.")
End If
area = (Single.Parse(sqarea.Text))
length = (Single.Parse(sqlth.Text))
area = length * length
sqarea.Text = (area & " units²")
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
sqlth.Text = ("")
sqarea.Text = ("")
sqper.Text = ("")
RichTextBox1.Text = ("")
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim length As Single
Dim peri As Single
If Not sqper.Text Is DBNull.Value Then
sqper.Text = "0"
End If
If Not IsNumeric(sqlth.Text) Then
sqlth.Text = "0"
RichTextBox1.Text = ("Error 1: Input was not a number. Strings such as 'apple', 'banana', 'x', or '2y' will trigger this error. Instead try and use a postive real number like '20', '310', or '20.5'.")
End If
length = sqlth.Text
peri = length * 4
sqper.Text = (peri & " units")
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
RichTextBox1.Text = ("This figure will help you to solve for the side length(s), area, and perimeter of a square. Fill in the length box with your length and click the 'Solve for Area' or 'Solve for Perimeter' to find the area or perimeter, respectively. If you are solving for the length, fill in for the area or perimeter and click the 'Solve for Length, Given Area' or 'Solve for Length, Given Perimeter'.")
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Dim area As Single
Dim length As Single
If sqarea.Text = "" Then
sqarea.Text = "0"
End If
If Not sqlth.Text Is DBNull.Value Then
sqlth.Text = "0"
End If
If Not IsNumeric(sqarea.Text) Then
sqarea.Text = "0"
RichTextBox1.Text = ("Error 1: Input was not a number. Strings such as 'apple', 'banana', 'x', or 'y' will trigger this error. Instead try and use a postive real number like '20', '310', or '20.5'.")
End If
area = (Single.Parse(sqarea.Text))
length = (Single.Parse(sqlth.Text))
length = Math.Sqrt(area)
sqlth.Text = (length & " units")
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
Dim peri As Single
Dim length As Single
If sqper.Text = "" Then
sqper.Text = "0"
End If
If Not sqlth.Text Is DBNull.Value Then
sqlth.Text = "0"
End If
If Not IsNumeric(sqper.Text) Then
sqper.Text = "0"
RichTextBox1.Text = ("Error 1: Input was not a number. Strings such as 'apple', 'banana', 'x', or 'y' will trigger this error. Instead try and use a postive real number like '20', '310', or '20.5'.")
End If
peri = (Single.Parse(sqper.Text))
length = (Single.Parse(sqlth.Text))
length = peri / 4
sqlth.Text = (length & " units")
End Sub
End Class
It works (as of now), including decimals.
![Biggrin Biggrin](https://sinister.ly/images/smilies/set/biggrin.png)