📄 frmimport.frm
字号:
VERSION 5.00
Begin VB.Form frmimport
BackColor = &H00FFC0C0&
Caption = "寝室信息录入"
ClientHeight = 4260
ClientLeft = 60
ClientTop = 450
ClientWidth = 7230
Icon = "frmimport.frx":0000
LinkTopic = "Form2"
ScaleHeight = 4260
ScaleWidth = 7230
Begin VB.CommandButton Command2
BackColor = &H00FFC0C0&
Caption = "退出"
Height = 375
Left = 4560
Style = 1 'Graphical
TabIndex = 9
Top = 3120
Width = 1575
End
Begin VB.CommandButton Command1
BackColor = &H00FFC0C0&
Caption = "添加"
Height = 375
Left = 1680
Style = 1 'Graphical
TabIndex = 8
Top = 3120
Width = 1215
End
Begin VB.TextBox Text1
Height = 375
Index = 3
Left = 4320
TabIndex = 7
Top = 2040
Width = 1695
End
Begin VB.TextBox Text1
Height = 375
Index = 2
Left = 4320
TabIndex = 6
Top = 960
Width = 1695
End
Begin VB.TextBox Text1
Height = 375
Index = 1
Left = 1320
TabIndex = 5
Top = 2040
Width = 1815
End
Begin VB.TextBox Text1
Height = 375
Index = 0
Left = 1320
TabIndex = 4
Top = 960
Width = 1815
End
Begin VB.Label Label1
BackColor = &H00FFC0C0&
Caption = "专业:"
Height = 375
Index = 3
Left = 3600
TabIndex = 3
Top = 2040
Width = 735
End
Begin VB.Label Label1
BackColor = &H00FFC0C0&
Caption = "姓名:"
Height = 375
Index = 2
Left = 3600
TabIndex = 2
Top = 960
Width = 615
End
Begin VB.Label Label1
BackColor = &H00FFC0C0&
Caption = "系别:"
Height = 375
Index = 1
Left = 240
TabIndex = 1
Top = 2040
Width = 735
End
Begin VB.Label Label1
BackColor = &H00FFC0C0&
Caption = "寝室号:"
Height = 375
Index = 0
Left = 240
TabIndex = 0
Top = 960
Width = 735
End
End
Attribute VB_Name = "frmimport"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim mrc As ADODB.Recordset
Set mrc = New ADODB.Recordset
Dim strsql, sss As String
'判断输入正确与否
If Text1(0) = "" Or IsNumeric(Text1(0)) = False Then
sss = MsgBox("寝室号是否输入正确!", vbExclamation + vbOKOnly, "警告")
Text1(0).SetFocus
Exit Sub
End If
If Text1(1) = "" Or IsNumeric(Text1(1)) = True Then
sss = MsgBox("系别是否输入正确!", vbExclamation + vbOKOnly, "警告")
Text1(1).SetFocus
Exit Sub
End If
If Text1(2) = "" Or IsNumeric(Text1(2)) = True Then
sss = MsgBox("专业是否输入正确!", vbExclamation + vbOKOnly, "警告")
Text1(2).SetFocus
Exit Sub
End If
If Text1(3) = "" Or IsNumeric(Text1(3)) = True Then
sss = MsgBox("姓名是否输入正确!", vbExclamation + vbOKOnly, "警告")
Text1(3).SetFocus
Exit Sub
End If
'判断有无重复输入
strsql = "select count(*) as num from bedchamber where 寝室号=" & Trim(Text1(0).Text) & " and 姓名='" & Trim(Text1(2).Text) & "'"
Set mrc = ExecuteSQL(strsql)
If mrc.Fields(0) <> 0 Then
sss = MsgBox("此人已经存在!", vbExclamation + vbOKOnly, "警告")
Exit Sub
End If
'加入数据库
strsql = "insert into bedchamber(寝室号,系别,姓名,专业) values(" & Text1(0) & ",'" & Text1(1) & "','" & Text1(2) & "','" & Text1(3) & "')"
Set mrc = ExecuteSQL(strsql)
Text1(0) = ""
Text1(1) = ""
Text1(2) = ""
Text1(3) = ""
End Sub
Private Sub Command2_Click()
Unload Me
frmdefault.Show
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -