📄 addstudinfo.frm
字号:
Caption = "备注:"
Height = 255
Index = 7
Left = 600
TabIndex = 30
Top = 3720
Width = 855
End
Begin VB.Label Label1
Caption = "家庭电话:"
Height = 255
Index = 6
Left = 240
TabIndex = 29
Top = 3360
Width = 975
End
Begin VB.Label Label1
Caption = "邮政编码:"
Height = 255
Index = 5
Left = 240
TabIndex = 28
Top = 2880
Width = 975
End
Begin VB.Label Label1
Caption = "家庭地址:"
Height = 255
Index = 4
Left = 240
TabIndex = 27
Top = 2400
Width = 975
End
Begin VB.Label Label1
Caption = "宿舍电话:"
Height = 255
Index = 3
Left = 3000
TabIndex = 26
Top = 1943
Width = 975
End
Begin VB.Label Label1
Caption = "宿舍号码:"
Height = 255
Index = 2
Left = 240
TabIndex = 25
Top = 1950
Width = 975
End
Begin VB.Label Label1
Caption = "学号:"
Height = 255
Index = 0
Left = 600
TabIndex = 13
Top = 510
Width = 615
End
Begin VB.Label Label3
Caption = "性别:"
Height = 255
Left = 3000
TabIndex = 12
Top = 503
Width = 615
End
Begin VB.Label Label4
Caption = "班级:"
Height = 255
Left = 4800
TabIndex = 11
Top = 960
Width = 615
End
Begin VB.Label Label1
Caption = "姓名:"
Height = 255
Index = 1
Left = 600
TabIndex = 10
Top = 960
Width = 615
End
Begin VB.Label Label1
Caption = "年级:"
Height = 255
Index = 8
Left = 3000
TabIndex = 9
Top = 863
Width = 615
End
End
Begin VB.Label Label2
Caption = "学生信息"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3600
TabIndex = 14
Top = 120
Width = 1215
End
End
Attribute VB_Name = "addStudInfo"
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
If Not Testtxt(Text1(0)) Then
MsgBox "请输入学号!", vbOKOnly + vbExclamation, "警告"
Text1(0).SetFocus
Exit Sub
End If
If Not Testtxt(Text1(1)) Then
MsgBox "请输入姓名!", vbOKOnly + vbExclamation, "警告"
Text1(1).SetFocus
Exit Sub
End If
If Not Testtxt(Combo1.Text) Then
MsgBox "请选择性别!", vbOKOnly + vbExclamation, "警告"
Combo1.SetFocus
Exit Sub
End If
If Not Testtxt(Text1(2).Text) Then
MsgBox "请输宿舍号码!", vbOKOnly + vbExclamation, "警告"
Text1(2).SetFocus
Exit Sub
End If
If Not Testtxt(Text1(3).Text) Then
MsgBox "请输入宿舍电话!", vbOKOnly + vbExclamation, "警告"
Text1(3).SetFocus
Exit Sub
End If
If Not Testtxt(Text1(4).Text) Then
MsgBox "请输入家庭住址!", vbOKOnly + vbExclamation, "警告"
Text1(4).SetFocus
Exit Sub
End If
If Not Testtxt(Text1(5).Text) Then
MsgBox "请输入邮政编码!", vbOKOnly + vbExclamation, "警告"
Text1(5).SetFocus
Exit Sub
End If
If Not Testtxt(Text1(6).Text) Then
MsgBox "请输入家庭电话!", vbOKOnly + vbExclamation, "警告"
Text1(6).SetFocus
Exit Sub
End If
txtSQL1 = "select * from stud where 学号='" & Trim(Text1(0).Text) & "'"
Set mrc = ExecuteSQL(txtSQL1)
If modi = False Then
If mrc.EOF = False Then
sss = MsgBox("已经存在该学号的记录,学号不能重复!", vbExclamation + vbOKOnly, "警告")
Text1(0).SetFocus
Text1(0).SelStart = 0
Text1(0).SelLength = Len(Text1(0).Text)
mrc.Close
Exit Sub
End If
End If
If modi = True Then
txtSQL1 = "update stud set 学号='" & Trim(Text1(0).Text) & "',姓名='" & Trim(Text1(1).Text) & "',性别='" & Trim(Combo0.Text) & "',年级='" & Trim(Combo15.Text) & "',班级='" & Trim(Combo16.Text) & "',出生年月=" & Trim(Combo3.Text + Combo4.Text + Combo5.Text) & "',宿舍号码='" & Trim(Text1(2).Text) & "',宿舍电话='" & Trim(Text1(3).Text) & "',家庭住址='" & Trim(Text1(4).Text) & "' ,邮政编码='" & Trim(Text1(5).Text) & "' ,家庭电话='" & Trim(Text1(6).Text) & "' ,备注='" & Trim(Text1(7).Text) & "',照片='" & Trim(Text1(8).Text) & "''"
Set mrc = ExecuteSQL(txtSQL1)
Unload Me
Exit Sub
End If
txtSQL1 = "select * from stud "
Set mrc = ExecuteSQL(txtSQL1)
mrc.AddNew
mrc.Fields(0) = Trim(Text1(0).Text)
mrc.Fields(1) = Trim(Text1(1).Text)
mrc.Fields(2) = Trim(Combo1.Text)
mrc.Fields(3) = Trim(Combo5.Text)
mrc.Fields(4) = Trim(Combo6.Text)
mrc.Fields(5) = Trim(Combo2.Text + Combo3.Text + Combo4.Text)
mrc.Fields(6) = Trim(Text1(2).Text)
mrc.Fields(7) = Trim(Text1(3).Text)
mrc.Fields(8) = Trim(Text1(4).Text)
mrc.Fields(9) = Trim(Text1(5).Text)
mrc.Fields(10) = Trim(Text1(6).Text)
mrc.Fields(11) = Trim(Text1(7).Text)
mrc.Fields(12) = Trim(Text1(8).Text)
mrc.Update
Set mrc = Nothing
For j = 0 To 8
Text1(j).Text = ""
Next
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
Form1.Show
End Sub
Private Sub Form_Activate()
Text1(0).SetFocus
End Sub
Private Sub Form_Unload(Cancel As Integer)
frmMain.Enabled = True
End Sub
Private Sub Image1_DblClick()
Form1.Show
End Sub
Private Sub Text1_GotFocus(Index As Integer)
Text1(Index).SelStart = 0
Text1(Index).SelLength = Len(Text1(Index).Text)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -