Option Strict On 'VisualBasic2008 'テキストボックスを2つ、ボタンを3つ用意 '2つのテキストボックスに入力された整数の和を求める Public Class Form1 Private Function Calc(ByVal calcA As Integer, ByVal calcB As Integer) As Integer Return calcA + calcB End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If Not IsNumeric(TextBox1.Text) Then MsgBox("左側の入力が間違ってるぜ!") ElseIf Not IsNumeric(TextBox2.Text) Then MsgBox("右側の入力が間違ってるぜ!") Else MsgBox(Calc(CInt(TextBox1.Text), CInt(TextBox2.Text)) End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If Not IsNumeric(TextBox1.Text) Then GoTo 10 If Not IsNumeric(TextBox2.Text) Then GoTo 20 GoTo 30 10: MsgBox("左側の入力が間違ってるぜ!") 20: MsgBox("右側の入力が間違ってるぜ!") Return 30: MsgBox(Calc(CInt(TextBox1.Text), CInt(TextBox2.Text)) End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Select Case True Case Not IsNumeric(TextBox1.Text) MsgBox("左側の入力が間違ってるぜ!") Case Not IsNumeric(TextBox2.Text) MsgBox("右側の入力が間違ってるぜ!") Case Else MsgBox(Calc(CInt(TextBox1.Text), CInt(TextBox2.Text)) End Select End Sub End Class