VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   2655
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4635
   LinkTopic       =   "Form1"
   ScaleHeight     =   2655
   ScaleWidth      =   4635
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "计算"
      Height          =   510
      Left            =   1470
      TabIndex        =   3
      Top             =   1860
      Width           =   1350
   End
   Begin VB.TextBox Text1 
      Height          =   345
      Left            =   1635
      TabIndex        =   1
      Top             =   210
      Width           =   1410
   End
   Begin VB.Label Label2 
      Caption         =   "Label2"
      Height          =   630
      Left            =   465
      TabIndex        =   2
      Top             =   840
      Width           =   3255
   End
   Begin VB.Label Label1 
      Caption         =   "请输入年份："
      Height          =   270
      Left            =   315
      TabIndex        =   0
      Top             =   255
      Width           =   1155
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
    Dim f1 As Boolean, f2 As Boolean, f3 As Boolean  '定义逻辑变量
    Dim Year As Integer                              '定义整型变量
    
    Year = Val(Text1.Text)                     '将文本框字符串转化为数值型赋给f1
    If Int(Year / 4) * 4 = Year Then f1 = True '判断年份是否被4整除，将结果存入f1
    If Int(Year / 100) * 100 = Year Then f2 = True '判断年份是否被100整除，将结果存入f2
    If Int(Year / 400) * 400 = Year Then f3 = True '判断年份是否被400整除，将结果存入f3
    If f1 And Not f2 Or f2 And f3 Then           '判断是否为闰年
        Label2.Caption = Text1.Text + "是闰年"
        Label2.ForeColor = RGB(255, 0, 0)
        Label2.FontSize = 20
    Else
        Label2.Caption = Text1.Text + "不是闰年"
        Label2.ForeColor = RGB(0, 0, 255)
        Label2.FontSize = 20
    End If
End Sub

