2012年6月14日 星期四

生肖查詢

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim y, n As Short
        y = TextBox1.Text
        Val(y)
        If y < 1911 Or y > Year(Today) Then
            MsgBox("您輸入的年份錯誤,須介於1911~" & Year(Today), , "輸入錯誤")
            TextBox1.Text = ""
            RadioButton1.Checked = False
            RadioButton2.Checked = False
            RadioButton3.Checked = False
            RadioButton4.Checked = False
            RadioButton5.Checked = False
            RadioButton6.Checked = False
            RadioButton7.Checked = False
            RadioButton8.Checked = False
            RadioButton9.Checked = False
            RadioButton10.Checked = False
            RadioButton11.Checked = False
            RadioButton12.Checked = False
        End If
        y = y - 4
        n = y Mod 12
        Select Case n
            Case 0 : RadioButton1.Checked = True
            Case 1 : RadioButton2.Checked = True
            Case 2 : RadioButton3.Checked = True
            Case 3 : RadioButton4.Checked = True
            Case 4 : RadioButton5.Checked = True
            Case 5 : RadioButton6.Checked = True
            Case 6 : RadioButton7.Checked = True
            Case 7 : RadioButton8.Checked = True
            Case 8 : RadioButton9.Checked = True
            Case 9 : RadioButton10.Checked = True
            Case 10 : RadioButton11.Checked = True
            Case 11 : RadioButton12.Checked = True
        End Select
    End Sub
End Class

沒有留言:

張貼留言

您好,您可以以匿名方式或登入來留言.當您完成留言後請先按下"預覽"然後再按"發佈";您可以在留言內容中最上方加入"--隱藏--",您的留言便不會被公開,如果您沒有加入--隱藏--您的留言就會在被管理員確認後公開.