VB程序代码,请各位指教

来源:百度知道 编辑:UC知道 时间:2024/06/06 16:57:49
Dim y As Integer
y = Text1.Text
If y Mod 4 = o And y Mod 100 <> 0 Or y Mod 400 = 0 Then
x = MsgBox(它是闰年, vbOKOnly, vbInformation, "判断")
If x = 1 Then
Text1.Text = ""
Text1.SetFocus
Else
x = MsgBox(它是闰年, vbOKOnly, vbInformation, "判断")(运行时输入一个闰年数字后出现错误,调试时总是提示这行错了)
End If
End If

Private Sub Command1_Click()
Dim y As Integer
y = Text1.Text
If y Mod 4 = o And y Mod 100 <> 0 Or y Mod 400 = 0 Then
x = MsgBox("它是闰年", vbOKOnly + vbInformation, "判断")
If x = 1 Then
Text1.Text = ""
Text1.SetFocus
Else
x = MsgBox("它是闰年", vbOKOnly + vbInformation, "判断")
End If
End If
End Sub

应是x = MsgBox(它是闰年, vbOKOnly,"判断"),你多写了一项。

y是整数值,可是文本的内容是字符型的。应该把第一句写成:y=val(text1.text)