📄 frmquery.frm
字号:
VERSION 5.00
Begin VB.Form frmQuery
BorderStyle = 3 'Fixed Dialog
Caption = "查询"
ClientHeight = 4905
ClientLeft = 45
ClientTop = 330
ClientWidth = 7275
Icon = "frmQuery.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4905
ScaleWidth = 7275
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox txtTotalTime
Height = 315
Left = 5820
TabIndex = 12
Top = 4395
Width = 1305
End
Begin VB.CommandButton cmdClose
Caption = "关闭"
Height = 360
Left = 6480
TabIndex = 10
Top = 30
Width = 735
End
Begin VB.CommandButton cmdShowAll
Caption = "显示全部"
Height = 345
Left = 3405
TabIndex = 4
Top = 60
Width = 1125
End
Begin VB.CommandButton cmdQuery
Caption = "查询"
Height = 345
Left = 2700
TabIndex = 3
Top = 60
Width = 570
End
Begin VB.TextBox txtID
Height = 330
Left = 1050
TabIndex = 0
Top = 60
Width = 1590
End
Begin VB.ListBox List1
Height = 3300
Left = 180
TabIndex = 1
Top = 915
Width = 6915
End
Begin VB.Line Line1
X1 = 120
X2 = 7200
Y1 = 480
Y2 = 480
End
Begin VB.Label Label5
Caption = "总使用时间"
Height = 240
Left = 4770
TabIndex = 11
Top = 4470
Width = 1020
End
Begin VB.Label Label4
Caption = "使用时间(小时)"
Height = 300
Left = 5880
TabIndex = 9
Top = 645
Width = 1455
End
Begin VB.Label Label3
Caption = "结束时刻"
Height = 330
Left = 4560
TabIndex = 8
Top = 630
Width = 840
End
Begin VB.Label Label2
Caption = "开始时刻"
Height = 255
Left = 2505
TabIndex = 7
Top = 645
Width = 750
End
Begin VB.Label Label1
Caption = "学号"
Height = 210
Left = 1125
TabIndex = 6
Top = 645
Width = 480
End
Begin VB.Label 计算号
Caption = "计算号"
Height = 255
Left = 180
TabIndex = 5
Top = 645
Width = 570
End
Begin VB.Label lblID
Caption = "计算机号或学号"
Height = 210
Left = 225
TabIndex = 2
Top = 135
Width = 1260
End
End
Attribute VB_Name = "frmQuery"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Option Base 1
Dim his() As Info
Dim intNum As Integer
Public mode As Boolean
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdQuery_Click()
Dim i As Integer
Dim str1 As String
Dim sngTotalTime As Single
str1 = txtID.Text
If mode Then
List1.Clear
For i = 1 To intNum
If his(i).ComputerID = Val(str1) - 1 Then
List1.AddItem Format(his(i).ComputerID + 1, "00") & Space(4) & his(i).StudentID & Space(4) & Format(his(i).Start, "yyyy-mm-dd hh:nn:ss") & Space(4) & Format(his(i).End, "yyyy-mm-dd hh:nn:ss") & Space(4) & Format((his(i).End - his(i).Start) * 24, "0.00")
sngTotalTime = sngTotalTime + (his(i).End - his(i).Start) * 24
End If
Next
Else
If Len(str1) <> 10 Then
MsgBox ("请输入10位学号")
Exit Sub
End If
List1.Clear
For i = 1 To intNum
If his(i).StudentID = Trim(str1) Then
List1.AddItem Format(his(i).ComputerID + 1, "00") & Space(4) & his(i).StudentID & Space(4) & Format(his(i).Start, "yyyy-mm-dd hh:nn:ss") & Space(4) & Format(his(i).End, "yyyy-mm-dd hh:nn:ss") & Space(4) & Format((his(i).End - his(i).Start) * 24, "0.00")
sngTotalTime = sngTotalTime + (his(i).End - his(i).Start) * 24
End If
Next
End If
txtTotalTime.Text = Format(sngTotalTime, "#.00") & " 小时"
End Sub
Private Sub cmdShowAll_Click()
Dim i As Integer
Dim str1 As String
Dim sngTotalTime As Single
List1.Clear
For i = 1 To intNum
List1.AddItem Format(his(i).ComputerID + 1, "00") & Space(4) & his(i).StudentID & Space(4) & Format(his(i).Start, "yyyy-mm-dd hh:nn:ss") & Space(4) & Format(his(i).End, "yyyy-mm-dd hh:nn:ss") & Space(4) & Format((his(i).End - his(i).Start) * 24, "0.00")
sngTotalTime = sngTotalTime + (his(i).End - his(i).Start) * 24
Next
txtTotalTime.Text = Format(sngTotalTime, "#.00") & " 小时"
End Sub
Private Sub Form_Load()
Dim info1 As Info
Dim i As Integer
Dim sngTotalTime As Single
If mode Then
lblID.Caption = "计算机号"
txtID.MaxLength = 2
Else
lblID.Caption = "学生学号"
txtID.MaxLength = 10
End If
If Dir(App.Path & "\his.dat") <> "" Then
Open App.Path & "\his.dat" For Random As 1 Len = Len(info1)
intNum = LOF(1) / Len(info1)
For i = 1 To intNum
ReDim Preserve his(i)
Get #1, i, his(i) '读入
List1.AddItem Format(his(i).ComputerID + 1, "00") & Space(4) & his(i).StudentID & Space(4) & Format(his(i).Start, "yyyy-mm-dd hh:nn:ss") & Space(4) & Format(his(i).End, "yyyy-mm-dd hh:nn:ss") & Space(4) & Format((his(i).End - his(i).Start) * 24, "0.00")
sngTotalTime = sngTotalTime + (his(i).End - his(i).Start) * 24
Next
Close 1
txtTotalTime.Text = Format(sngTotalTime, "#.00") & " 小时"
Else
Erase his()
intNum = 0
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -