Leisureeen

导航

ExamTime

‎July ‎29, ‎2019那天晚上写的一个VB小程序,主要用于PAT考试的计时。

 

主界面窗体文件(main.frm):

VERSION 5.00
Begin VB.Form main 
   BackColor       =   &H00FFFF00&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "ExamTime"
   ClientHeight    =   4710
   ClientLeft      =   45
   ClientTop       =   375
   ClientWidth     =   9375
   MaxButton       =   0   'False
   ScaleHeight     =   4710
   ScaleWidth      =   9375
   StartUpPosition =   2  '屏幕中心
   Begin VB.Timer TimeT 
      Interval        =   200
      Left            =   480
      Top             =   3720
   End
   Begin VB.TextBox inData 
      BackColor       =   &H00FFFF00&
      BorderStyle     =   0  'None
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   3840
      TabIndex        =   4
      Top             =   480
      Width           =   4935
   End
   Begin VB.TextBox out 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2055
      Left            =   240
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   2
      Top             =   1200
      Width           =   8895
   End
   Begin VB.CommandButton timeB 
      Caption         =   "Time"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   2280
      TabIndex        =   1
      Top             =   3600
      Width           =   1695
   End
   Begin VB.CommandButton exitB 
      Caption         =   "Exit"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   5400
      TabIndex        =   0
      Top             =   3600
      Width           =   1695
   End
   Begin VB.Label ShowTime 
      BackStyle       =   0  'Transparent
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   600
      TabIndex        =   3
      Top             =   480
      Width           =   2895
   End
End
Attribute VB_Name = "main"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub exitB_Click()
    End
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    exitB_Click
End Sub

Private Sub timeB_Click()
    Dim str As String, tmpT As String, md As String
    timeB.Enabled = False
    str = getTime & " " & inData.Text
    tmpT = Year(Date)
    md = Month(Date)
    If Val(md) < 10 Then tmpT = tmpT & "0"
    tmpT = tmpT & md
    md = Day(Date)
    If Val(md) < 10 Then tmpT = tmpT & "0"
    tmpT = tmpT & md
    out.Text = str & vbCrLf & out.Text
    On Error Resume Next
    Open App.Path & "\" & tmpT & "Exam.txt" For Append As #1
        Print #1, str
    Close #1
    timeB.Enabled = True
End Sub

Private Sub TimeT_Timer()
    ShowTime.Caption = getTime
End Sub

Private Function getTime() As String
    Dim min As String, sec As String
    getTime = Year(Date) & "-" & Month(Date) & "-" & Day(Date) & " " & Hour(Time) & ":"
    min = Minute(Time)
    If Val(min) < 10 Then getTime = getTime & "0"
    getTime = getTime & min & ":"
    sec = Second(Time)
    If Val(sec) < 10 Then getTime = getTime & "0"
    getTime = getTime & sec
End Function

 

posted on 2020-04-18 17:32  Leisureeen  阅读(247)  评论(0编辑  收藏  举报

JS