------------------
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim n As Integer
Dim angle As Double
' TextBox1に入力された値を整数に変換
If Integer.TryParse(TextBox1.Text, n) AndAlso n >= 3 Then
' 正多角形の内角の角度を計算
angle = ((n - 2) * 180) / n
' 角度が偶数かどうかを確認
If angle Mod 2 = 0 Then
' 偶数の場合
Label4.ForeColor = Color.Empty
Label4.Text = angle.ToString("F0") & " 度"
Label6.ForeColor = Color.Empty
Label6.Text = "偶数"
Else
' 奇数の場合、小数点以下4桁まで表示
Label4.ForeColor = Color.Blue
Label4.Text = angle.ToString("F10") & " 度"
Label6.ForeColor = Color.Blue
Label6.Text = "奇数"
End If
Else
' 有効な値が入力されていない場合
Label4.ForeColor = Color.Red
Label4.Text = "正多角形は3以上の整数です"
Label6.ForeColor = Color.Red
Label6.Text = "計算できません"
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
TextBox1.ResetText()
Label4.ResetText()
Label4.ForeColor = Color.Empty
Label6.ResetText()
Label6.ForeColor = Color.Empty
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
End
End Sub
End Class
------------------