📄 edks1.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form edks1
Caption = "编辑考生纪录"
ClientHeight = 4605
ClientLeft = 60
ClientTop = 450
ClientWidth = 5820
LinkTopic = "Form3"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4605
ScaleWidth = 5820
StartUpPosition = 2 '屏幕中心
Begin MSComDlg.CommonDialog CommonDialog1
Left = 1560
Top = 240
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Comm2
Caption = "取消"
Height = 375
Left = 3240
TabIndex = 17
Top = 4080
Width = 855
End
Begin VB.CommandButton Comm1
Caption = "确定"
Height = 375
Left = 1680
TabIndex = 16
Top = 4080
Width = 855
End
Begin VB.OptionButton Opt2
Caption = "女"
Height = 375
Left = 4200
TabIndex = 6
Top = 960
Width = 495
End
Begin VB.OptionButton Opt1
Caption = "男"
Height = 375
Left = 3480
TabIndex = 5
Top = 960
Width = 615
End
Begin VB.Frame Frame1
Caption = "考生记录"
Height = 3495
Left = 360
TabIndex = 0
Top = 360
Width = 5175
Begin VB.TextBox Text1
Height = 270
Index = 1
Left = 1320
TabIndex = 20
Top = 840
Width = 975
End
Begin VB.CommandButton SelCom
Caption = "..."
Height = 375
Left = 2400
TabIndex = 18
Top = 2400
Width = 495
End
Begin VB.TextBox Text1
Height = 270
Index = 5
Left = 1320
TabIndex = 15
Top = 2280
Width = 975
End
Begin VB.TextBox Text1
Height = 270
Index = 4
Left = 1320
TabIndex = 14
Top = 1920
Width = 975
End
Begin VB.TextBox Text1
Height = 270
Index = 3
Left = 1320
TabIndex = 13
Top = 1560
Width = 2535
End
Begin VB.TextBox Text1
Height = 270
Index = 2
Left = 1320
TabIndex = 12
Top = 1200
Width = 1335
End
Begin VB.TextBox Text1
Height = 270
Index = 0
Left = 1320
TabIndex = 10
Top = 480
Width = 975
End
Begin VB.Frame Frame2
Caption = "性别"
Height = 735
Left = 3000
TabIndex = 4
Top = 360
Width = 1575
End
Begin VB.Image Image1
Height = 1335
Left = 3240
Stretch = -1 'True
Top = 1920
Width = 1215
End
Begin VB.Label Label8
Caption = "照片"
Height = 255
Left = 2520
TabIndex = 19
Top = 2160
Width = 375
End
Begin VB.Label Label7
Caption = "日期格式:yyyy-mm-dd"
Height = 255
Left = 2760
TabIndex = 11
Top = 1200
Width = 1815
End
Begin VB.Label Label6
Caption = "准考证号"
Height = 255
Left = 480
TabIndex = 9
Top = 2280
Width = 735
End
Begin VB.Label Label5
Caption = "邮政编码"
Height = 255
Left = 480
TabIndex = 8
Top = 1920
Width = 735
End
Begin VB.Label Label4
Caption = "通信地址"
Height = 255
Left = 480
TabIndex = 7
Top = 1560
Width = 735
End
Begin VB.Label Label3
Caption = "出生日期"
Height = 255
Left = 480
TabIndex = 3
Top = 1200
Width = 735
End
Begin VB.Label Label2
Caption = "姓 名"
Height = 255
Left = 480
TabIndex = 2
Top = 840
Width = 735
End
Begin VB.Label Label1
Caption = "报 名 号"
Height = 255
Left = 480
TabIndex = 1
Top = 480
Width = 735
End
End
Begin MSAdodcLib.Adodc Adodc1
Height = 330
Left = 2880
Top = 120
Visible = 0 'False
Width = 1575
_ExtentX = 2778
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 3
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "DSN=KS"
OLEDBString = ""
OLEDBFile = ""
DataSourceName = "KS"
OtherAttributes = ""
UserName = "yilin"
Password = "b606"
RecordSource = "ksb"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
End
Attribute VB_Name = "edks1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Const BlockSize = 100000
Dim NumBlocks As Integer
Dim FileLength As Long
Dim LeftOver As Long
Dim i As Integer
Dim n As Integer
Dim ByteData() As Byte
Dim FileName As String
Dim FileNum As Integer
Dim DiskFile As String
Private Sub Form_Load()
sel = False
DiskFile = App.Path & "\image1.bmp" '设置临时文件名
If flag = 2 Then '修改操作
Text1(0).Text = Trim(edks.Adodc1.Recordset.Fields("报名号"))
Text1(1).Text = Trim(edks.Adodc1.Recordset.Fields("姓名")) & ""
If edks.Adodc1.Recordset.Fields("性别") = "男" Then
Opt1.Value = True
ElseIf edks.Adodc1.Recordset.Fields("性别") = "女" Then
Opt2.Value = True
End If
Text1(2).Text = Trim(edks.Adodc1.Recordset.Fields("出生日期")) & ""
Text1(3).Text = Trim(edks.Adodc1.Recordset.Fields("通信地址")) & ""
Text1(4).Text = Trim(edks.Adodc1.Recordset.Fields("邮政编码")) & ""
Text1(5).Text = Trim(edks.Adodc1.Recordset.Fields("准考证号")) & ""
If edks.Adodc1.Recordset.Fields("照片长度") > 0 Then
'将当前纪录的照片数据存放到临时文件image1.bmp中
Me.MousePointer = vbHourglass
FileLength = edks.Adodc1.Recordset("照片长度")
If FileLength > 10000 Then
n = 5
Else
n = 10
End If
If Len(Dir$(DiskFile)) > 0 Then
Kill DiskFile '删除原来存在的临时文件
End If
FileNum = FreeFile()
Open DiskFile For Binary Access Write As FileNum '打开文件
NumBlocks = FileLength \ (BlockSize \ n)
'计算块数目,每块的大小为BlockSize\n
LeftOver = FileLength Mod (BlockSize \ n) '余下的长度
ReDim ByteData(BlockSize \ n)
For i = 1 To NumBlocks
'将每个照片数据块写入ByteData数组中,由它写入文件中
ByteData() = edks.Adodc1.Recordset("照片").GetChunk(BlockSize \ n)
Put FileNum, , ByteData
Next i
If LeftOver > 0 Then
'将余下的照片数据写入ByteData数组中,由它写入文件中
ReDim ByteData(LeftOver)
ByteData() = edks.Adodc1.Recordset("照片").GetChunk(LeftOver)
Put FileNum, , ByteData
End If
Close FileNum '关闭文件
Image1.Picture = LoadPicture(DiskFile)
Me.MousePointer = vbNormal
Else
Image1.Picture = LoadPicture()
End If
Else '添加操作
Image1.Picture = LoadPicture()
num = num + 1
Text1(0).Text = Trim(Str(num))
End If
End Sub
Private Sub Comm1_Click()
If Trim(Text1(1).Text) = "" Then
MsgBox "加*数据项不能为空,请重新设置", vbOKOnly, "信息提示"
Text1(1).SetFocus
Exit Sub
End If
If Trim(Text1(2).Text) <> "" Then
If Not IsDate(Trim(Text1(2).Text)) Then
MsgBox "出生日期输入不正确,重新输入", vbOKOnly, "信息提示"
Text1(1).SetFocus
Exit Sub
End If
End If
If flag = 1 Then '添加操作
recs = recs + 1
edks.Adodc1.Recordset.AddNew
End If
edks.Adodc1.Recordset.Fields("报名号") = Trim(Text1(0).Text)
edks.Adodc1.Recordset.Fields("姓名") = Trim(Text1(1).Text)
If Opt1.Value = True Then
edks.Adodc1.Recordset.Fields("性别") = "男"
ElseIf Opt2.Value = True Then
edks.Adodc1.Recordset.Fields("性别") = "女"
Else
edks.Adodc1.Recordset.Fields("性别") = ""
End If
If Trim(Text1(2).Text) <> "" Then
edks.Adodc1.Recordset.Fields("出生日期") = Format(Trim(Text1(2).Text), "yyyy-mm-dd")
End If
edks.Adodc1.Recordset.Fields("通信地址") = Trim(Text1(3).Text)
edks.Adodc1.Recordset.Fields("邮政编码") = Trim(Text1(4).Text)
edks.Adodc1.Recordset.Fields("合格否") = False
edks.Adodc1.Recordset.Fields("数学") = 0
edks.Adodc1.Recordset.Fields("外语") = 0
edks.Adodc1.Recordset.Fields("政治") = 0
edks.Adodc1.Recordset.Fields("专业课") = 0
edks.Adodc1.Recordset.Fields("总分") = 0
FileName = Trim(CommonDialog1.FileName) '将图像文件数据写到照片字段中
If sel = True Then '用户制定了新图像
Image1.Picture = LoadPicture(FileName)
Me.MousePointer = vbHourglass
FileNum = FreeFile()
Open FileName For Binary Access Read As FileNum '打开临时文件
FileLength = LOF(FileNum)
If FileLength = 0 Then
Close FileNum
MsgBox "制定的图像文件不存在", 0, "信息提示"
Else
NumBlocks = FileLength \ BlockSize '块数
LeftOver = FileLength Mod BlockSize '余下的长度
ReDim ByteData(LeftOver)
Get FileNum, , ByteData()
edks.Adodc1.Recordset("照片").AppendChunk ByteData()
ReDim ByteData(BlockSize)
For i = 1 To NumBlocks
Get FileNum, , ByteData()
edks.Adodc1.Recordset("照片").AppendChunk ByteData()
Next i
edks.Adodc1.Recordset("照片长度") = FileLength
End If
Close FileNum
Me.MousePointer = vbNormal
End If
edks.Adodc1.Recordset.Update
Unload Me
End Sub
Private Sub Comm2_Click() '取消
Unload Me
End Sub
Private Sub selcom_click() '用于选取一个图像文件作为照片
With CommonDialog1
.Filter = "pictures(*.bmp;*.jpg|*.bmp;*.jpg"
.ShowOpen
End With
If CommonDialog1.FileName <> "" Then
Image1.Picture = LoadPicture(CommonDialog1.FileName)
sel = True
End If
End Sub
Private Sub text1_KeyPress(Index As Integer, KeyAscii As Integer)
Call endata(KeyAscii)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -