Option Strict On '環境 'Vista 'Visual Basic 2008 '条件 'ComboBox1,Label1,Button1をForm1に配置する Public Class Form1 Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Button1.Text = "解答" Label1.Text = "問題1__>徳川家康の幼名は?" With Me.ComboBox1.Items .Add("虎千代") .Add("松千代") .Add("影千代") .Add("竹千代") End With ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If ComboBox1.Text = Nothing Then MsgBox("何も選択されてないよ♪") : Return End If If MessageBox.Show(ComboBox1.Text, "解答", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = _ DialogResult.No Then Return End If Select Case ComboBox1.SelectedIndex Case 0, 1, 2 MsgBox("不正解です") Case 3 MsgBox("正解です") End Select End Sub End Class