• 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
  • 相关阅读:
    游戏中的角色移动:闭包(closure)在实际开发中的作用
    第六章 函数[DDT书本学习 小甲鱼]【1】
    Python模块EasyGui专题学习
    第十章 图形用户界面入门[DDT书本学习 小甲鱼]【1】
    第五章 列表、元组和字符串[DDT书本学习 小甲鱼]【7】
    ueditor 配置和上传图片
    常用的48个jQuery小技术点
    js 全选 ,全不选,反选的实现
    一个简单的登录页面,效果不错哦!
    关于模态框的引入
  • 原文地址:https://www.cnblogs.com/leisureeen/p/12726987.html
Copyright © 2020-2023  润新知