📄 form3.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Form3
BackColor = &H00C0C0FF&
Caption = "Form3"
ClientHeight = 5835
ClientLeft = 5490
ClientTop = 2070
ClientWidth = 4770
LinkTopic = "Form3"
ScaleHeight = 5835
ScaleWidth = 4770
Begin VB.CommandButton Command3
Caption = "返回"
Height = 495
Left = 3480
TabIndex = 5
Top = 5280
Width = 975
End
Begin VB.CommandButton Command2
Caption = "删除"
Height = 495
Left = 1920
TabIndex = 4
Top = 5280
Width = 975
End
Begin VB.CommandButton Command1
Caption = "修改"
Height = 495
Left = 360
TabIndex = 3
Top = 5280
Width = 975
End
Begin VB.TextBox Text1
Height = 375
Left = 3240
TabIndex = 1
Text = "Text1"
Top = 4800
Width = 1455
End
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1
Height = 4575
Left = 120
TabIndex = 0
Top = 120
Width = 4695
_ExtentX = 8281
_ExtentY = 8070
_Version = 393216
Rows = 100
Cols = 5
FixedRows = 0
FixedCols = 0
End
Begin VB.Label Label2
Caption = "请输入所要删除的学生信息的学号:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 0
TabIndex = 6
Top = 4920
Width = 3375
End
Begin VB.Label Label1
Caption = "请输入所要修改的学生信息的学号:"
BeginProperty Font
Name = "楷体_GB2312"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 0
TabIndex = 2
Top = 4920
Width = 3375
End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Function StuList_update()
Dim rs As New ADODB.Recordset
Dim sql As String
sql = "select * from 学生信息"
Dim i As Integer
Set rs = TransactSQL(sql)
With MSFlexGrid1
.Rows = 1
While Not rs.EOF
.Rows = .Rows + 1
.TextMatrix(.Rows - 1, 0) = rs(0)
.TextMatrix(.Rows - 1, 1) = rs(1)
'.TextMatrix(.Rows - 1, 2) = rs(2)
.TextMatrix(.Rows - 1, 3) = rs(3)
.TextMatrix(.Rows - 1, 4) = rs(4)
If rs("stu_sex") = 0 Then
MSFlexGrid1.TextMatrix(.Rows - 1, 2) = "男"
Else
MSFlexGrid1.TextMatrix(.Rows - 1, 2) = "女"
End If
rs.MoveNext
Wend
End With
End Function
Private Sub Command1_Click()
Dim rs As New ADODB.Recordset
Dim sql As String
sql = "select * from 学生信息 where stu_Id ='" & Text1.Text & "'"
If Trim(Text1.Text) = "" Then
MsgBox "请输入所要修改的学生的的学号!", vbOKOnly
Else
Set rs = TransactSQL(sql)
If rs.EOF = True Then
MsgBox "没有该学号的学生信息!", vbOKOnly
Else
ModifyStFlag1 = Text1.Text
ModifyStFlag2 = True
Form2.Show
Form2.Refresh
Form2.Command1.Enabled = False
Form2.Command3.Enabled = True
Form2.Command2.Visible = False
Form2.Command4.Visible = True
rs.Close
End If
End If
End Sub
Private Sub Command2_Click()
Dim resMsg As String
Dim rs As New ADODB.Recordset
Dim sql As String
Dim sql2 As String
sql = "select stu_Id from 学生信息 where stu_Id = '" & Text1.Text & "'"
sql2 = "delete from 学生信息 where stu_Id = '" & Text1.Text & "'"
If Trim(Text1.Text) = "" Then
MsgBox "请输入要删除的学生信息的学号!", vbOKOnly, "提示!"
Else
Set rs = TransactSQL(sql)
If rs.EOF = True Then
MsgBox "没有该学号的学生信息!", vbOKOnly, "提示!"
rs.Close
Else
resMsg = MsgBox("真的要删除该学生的信息吗?", vbOKCancel, "警告!")
If resMsg = vbOK Then
TransactSQL (sql2)
MsgBox "该学生的信息已经删除!", vbOKOnly, "提示!"
Call StuList_update
End If
End If
End If
End Sub
Private Sub Command3_Click()
Unload Me
Form1.Show
End Sub
Private Sub Form_Load()
With MSFlexGrid1
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "性别"
.TextMatrix(0, 3) = "班级编号"
.TextMatrix(0, 4) = "学院编号"
'.ColWidth(3) = 1500
'.ColWidth(4) = 1800
'.ColWidth(7) = 1500
'.ColWidth(9) = 1200
'.ColWidth(13) = 1200
'.ColWidth(14) = 2000
.BackColorFixed = RGB(247, 214, 157)
End With
'显示表中数据
Call StuList_update
Text1.Text = ""
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -