I am making a calculator to switch from radius to diameter ect... but i keep getting this error (An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object.) I am not sure what to do and sorry if this is easy, i am a beginner. here is my code
and yes i know im not done but i get this error anyways
Public Class Form1
Dim Radius1 As Integer = Val(TextBox2.Text / 2)
Dim Radius2 As Integer = Val(TextBox3.Text / 3.14 / 2)
Dim Diameter1 As Integer = Val(TextBox1.Text * 2)
Dim Diameter2 As Integer = Val(TextBox3.Text / 3.14)
Dim Circumference1 As Integer = 3.14159 * Val(TextBox2.Text)
Dim Circumference2 As Integer = 3.14159 * Val(TextBox1.Text * 2 * 3.14)
Dim Radiusbox As Integer = Val(TextBox1.Text)
Dim Diameterbox As Integer = Val(TextBox2.Text)
Dim Circumferencebox As Integer = (TextBox3.Text)
Dim unit As String = TextBox4.Text
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If IsNumeric(Radiusbox) Then
ElseIf Radiusbox = "" Then
Else
TextBox1.BackColor = Color.Red
TextBox1.ForeColor = Color.White
End If
If IsNumeric(Diameterbox) Then
MsgBox("good")
ElseIf Diameterbox = "" Then
MsgBox("goodnone")
Else
TextBox2.BackColor = Color.Red
TextBox2.ForeColor = Color.White
End If
If IsNumeric(Circumferencebox) Then
ElseIf Circumferencebox = "" Then
Else
TextBox3.BackColor = Color.Red
TextBox3.ForeColor = Color.White
End If
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox1.BackColor = Color.White
TextBox1.ForeColor = Color.Black
End Sub
Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
TextBox1.Enabled = False
TextBox3.Enabled = False
TextBox2.BackColor = Color.White
TextBox2.ForeColor = Color.Black
End Sub
Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
TextBox2.Enabled = False
TextBox1.Enabled = False
TextBox3.BackColor = Color.White
TextBox3.ForeColor = Color.Black
End Sub
End Class
and yes i know im not done but i get this error anyways