表示整形:
Dim year As Integer
表示長整形:
Dim year As long
2個表示範圍不壹樣,不再贅述。
判斷閏年,用不著文本框,直接在窗體內顯示結果,用條件判斷語句即可,代碼如下:
Private Sub Form_Click()
Dim year As Integer
year = Val(InputBox("請輸入年份", "判斷閏年"))
If year Mod 400 = 0 Then
Print "公元"; year; "年是閏年"
Else
If year Mod 4 = 0 Then
Print "公元"; year; "年是閏年"
Else
Print "公元"; year; "年不是閏年"
End If
End If
End Sub