📄 frmdownload.frm
字号:
VERSION 5.00
Begin VB.Form FrmDownload
BackColor = &H00404040&
BorderStyle = 0 'None
ClientHeight = 2610
ClientLeft = 0
ClientTop = 0
ClientWidth = 6675
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2610
ScaleWidth = 6675
StartUpPosition = 1 '所有者中心
Begin VB.PictureBox PicPBar
BackColor = &H00404040&
Height = 285
Left = 360
ScaleHeight = 225
ScaleWidth = 5895
TabIndex = 3
Top = 1305
Width = 5955
End
Begin VB.CommandButton Command1
Caption = "进行考试"
Height = 375
Left = 2880
TabIndex = 2
Top = 1845
Visible = 0 'False
Width = 1050
End
Begin VB.PictureBox WskFileComm
Height = 480
Left = 720
ScaleHeight = 420
ScaleWidth = 1140
TabIndex = 4
Top = 585
Width = 1200
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 1000
Left = 1800
Top = 585
End
Begin VB.PictureBox WskFileBind
Height = 480
Left = 1260
ScaleHeight = 420
ScaleWidth = 1140
TabIndex = 5
Top = 585
Width = 1200
End
Begin VB.Label Label2
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "下载题库"
Height = 285
Left = 2475
TabIndex = 1
Top = 90
Width = 1635
End
Begin VB.Label Label1
Alignment = 2 'Center
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "正在下载题库请稍后"
ForeColor = &H00C0FFFF&
Height = 180
Left = 2610
TabIndex = 0
Top = 945
Width = 1620
End
Begin VB.Shape Shape1
BackColor = &H0000FFFF&
BackStyle = 1 'Opaque
BorderStyle = 6 'Inside Solid
Height = 375
Left = 0
Shape = 2 'Oval
Top = 0
Width = 6675
End
Begin VB.Line Line1
BorderColor = &H0080FFFF&
X1 = 0
X2 = 0
Y1 = 180
Y2 = 2565
End
Begin VB.Line Line2
BorderColor = &H0000FFFF&
X1 = 6660
X2 = 6660
Y1 = 180
Y2 = 2610
End
Begin VB.Line Line3
BorderColor = &H0000FFFF&
X1 = 0
X2 = 6660
Y1 = 2565
Y2 = 2565
End
End
Attribute VB_Name = "FrmDownload"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim CurrentFileLen As Long
Private TWForm As New TransWindow
Private PBar As New PicProgressBar
Private Sub Command1_Click()
Unload Me
Load FrmBuild
FrmBuild.Show
End Sub
Sub Init()
Dim CString As String * 255
If Dir(App.Path & "\Exambak.bak") <> Empty Then
GetPrivateProfileString "SubjectDB", "DBFileLen", "", CString, Len(CString), App.Path & "\ExamBak.bak"
FlieLenCount = Trim(CString)
End If
If Dir(App.Path & "\examktl.dll") = Empty Then
PBar.SetPic Me.PicPBar
PBar.picBarMax = DownFileLenCount
PBar.picBarMin = 0
PBar.picBarColor = &HFFC0C0
PBar.picTextColor = &H8000000F
PBar.picBarValue = 0
Timer1.Enabled = True
Label1.Caption = "连接服务器"
Else
If FileLen(App.Path & "\examktl.dll") < DownFileLenCount Then
Kill App.Path & "\examktl.dll"
PBar.SetPic Me.PicPBar
PBar.picBarMax = DownFileLenCount
PBar.picBarMin = 0
PBar.picBarColor = &HFFC0C0
PBar.picTextColor = &H4040&
PBar.picBarValue = 0
Timer1.Enabled = True
Label1.Caption = "连接服务器"
Else
Unload Me
Load FrmBuild
FrmBuild.Show
End If
End If
End Sub
Private Sub Form_Load()
'Me.Show
TWForm.SetForm Me
TWForm.ShowForm
Call Init
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
TWForm.UnLoadForm
Set TWForm = Nothing
Set PBar = Nothing
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = False
' WskFileComm.Close
' WskFileComm.Connect ServerIP, 10087
FrmMain.Winsock1.SendData "|SendFile|"
End Sub
Private Sub WskFileComm_Connect()
Timer1.Enabled = False
WskFileComm.SendData "|SendFile|"
End Sub
Private Sub WskFileComm_DataArrival(ByVal bytesTotal As Long)
On Error Resume Next
Dim fileBuff() As Byte
Dim FileNumber
'DoEvents
FileNumber = FreeFile
WskFileComm.GetData fileBuff, vbByte, bytesTotal
'---------------------------------------------
If CurrentFileLen = 0 Then
Open App.Path & "\examktl.dll" For Binary Access Read Write As #FileNumber
Put #FileNumber, 1, fileBuff
Close #FileNumber
Else
Open App.Path & "\examktl.dll" For Binary Access Read Write As #FileNumber
Put #FileNumber, CurrentFileLen + 1, fileBuff
Close #FileNumber
End If
'---------------------------------------------
If CurrentFileLen = 0 Then
CurrentFileLen = bytesTotal
Else
CurrentFileLen = CurrentFileLen + bytesTotal
End If
PBar.picBarValue = CurrentFileLen
Label1.Caption = "正在下载题库" & Round((CurrentFileLen / DownFileLenCount) * 100) & "%" & "已完成"
' If PB1.Value = PB1.Max Or PB1.Value > PB1.Max Or Round((CurrentFileLen / DownFileLenCount) * 100) = 100 Then
' PB1.Value = PB.Max
If PBar.picBarValue >= PBar.picBarMax Then
Label1.Caption = "下载完毕"
WskFileComm.SendData "|DownFile|"
Command1.Visible = True
'WskFileComm.Close
End If
End Sub
Private Sub WskFileComm_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
Label1.Caption = "服务器繁忙,正在尝试再次连接"
Timer1.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -