📄 findstu.frm
字号:
VERSION 5.00
Begin VB.Form Form2
Caption = "查找学生"
ClientHeight = 7170
ClientLeft = 60
ClientTop = 345
ClientWidth = 8040
LinkTopic = "Form2"
MaxButton = 0 'False
ScaleHeight = 7170
ScaleWidth = 8040
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox Text4
Height = 2295
Left = 720
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 9
Top = 4440
Width = 6135
End
Begin VB.ListBox List1
Height = 1320
Left = 720
TabIndex = 8
Top = 2880
Width = 6135
End
Begin VB.CommandButton Command2
Caption = "取消"
Height = 375
Left = 4320
TabIndex = 7
Top = 2280
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "查询"
Height = 375
Left = 2400
TabIndex = 6
Top = 2280
Width = 1215
End
Begin VB.TextBox Text3
Height = 375
Left = 3840
TabIndex = 5
Top = 1560
Width = 1575
End
Begin VB.TextBox Text2
Height = 375
Left = 3840
TabIndex = 4
Top = 840
Width = 1575
End
Begin VB.TextBox Text1
Height = 375
Left = 3840
TabIndex = 3
Top = 120
Width = 1575
End
Begin VB.OptionButton Option3
Caption = "按班级"
Height = 375
Left = 2280
TabIndex = 2
Top = 1560
Width = 1095
End
Begin VB.OptionButton Option2
Caption = "按学号"
Height = 495
Left = 2280
TabIndex = 1
Top = 840
Width = 1095
End
Begin VB.OptionButton Option1
Caption = "按姓名"
Height = 375
Left = 2280
TabIndex = 0
Top = 120
Width = 1095
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim ID As String
Private Sub Command1_Click()
Dim rs As New ADODB.Recordset
Dim find As String
Dim sql As String
List1.Clear
List1.AddItem "学号" & Space(5) & "姓名" & Space(5) & "班级"
If Option1.Value = True Then
sql = "select * from 学生管理 where 学生姓名='" & Text1.Text & "'"
rs.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs.EOF = False Then
rs.MoveFirst
While rs.EOF = False
List1.AddItem rs.Fields(0) & Space(5) & rs.Fields(1) & Space(5) & rs.Fields(2)
rs.MoveNext
Wend
Text1.Text = ""
Else
MsgBox "没有找到目标!", vbOKOnly + vbExclamation, ""
End If
End If
If Option2.Value = True Then
sql = "select * from 学生管理 where 学号='" & Text2.Text & "'"
rs.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs.EOF = False Then
rs.MoveFirst
While rs.EOF = False
List1.AddItem rs.Fields(0) & Space(5) & rs.Fields(1) & Space(5) & rs.Fields(2)
rs.MoveNext
Wend
Text2.Text = ""
Else
MsgBox "没有找到目标!", vbOKOnly + vbExclamation, ""
End If
End If
If Option3.Value = True Then
sql = "select * from 学生管理 where 班级='" & Text3.Text & "'"
rs.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs.EOF = False Then
rs.MoveFirst
While rs.EOF = False
List1.AddItem rs.Fields(0) & Space(5) & rs.Fields(1) & Space(5) & rs.Fields(2)
rs.MoveNext
Wend
Text3.Text = ""
Else
MsgBox "没有找到目标!", vbOKOnly + vbExclamation, ""
End If
End If
rs.Close
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub List1_Click()
Dim i As Long
Dim sql As String
Dim rsclick As New ADODB.Recordset
i = CLng(List1.ListIndex)
ID = Left(List1.Text, 6)
If i > 0 Then
rsclick.CursorLocation = adUseClient
sql = "select * from 学生操行 where 学号='" & ID & "'" & " order by 学期"
rsclick.Open sql, conn, adOpenKeyset, adLockPessimistic
If rsclick.EOF = False Then
rsclick.MoveFirst
Else
MsgBox "该生没有评语!", vbOKOnly + vbExclamation, ""
Exit Sub
End If
Text4.Text = "" '文本框清空
While rsclick.EOF = False
Text4.Text = Text4.Text & vbCrLf & "第" & rsclick.Fields(1) & "学期" & vbCrLf & Space(2) & _
rsclick.Fields(2) & vbCrLf & Space(10) & rsclick.Fields(3) & Space(2) & rsclick.Fields(4)
rsclick.MoveNext
Wend
rsclick.Close
Exit Sub
Else
MsgBox "请选择学生!", vbOKOnly + vbExclamation, ""
Exit Sub
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -