?? form3.frm
字號:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Form3
Caption = "Form3"
ClientHeight = 7170
ClientLeft = 60
ClientTop = 510
ClientWidth = 10335
LinkTopic = "Form3"
LockControls = -1 'True
ScaleHeight = 7170
ScaleWidth = 10335
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command3
Caption = "返回"
Height = 615
Left = 8280
TabIndex = 21
Top = 6240
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "確定"
Height = 615
Left = 6600
TabIndex = 20
Top = 6240
Width = 1215
End
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1
Height = 4455
Left = 120
TabIndex = 7
Top = 2520
Width = 6015
_ExtentX = 10610
_ExtentY = 7858
_Version = 393216
End
Begin VB.Frame Frame2
Caption = "修改輸入"
Height = 5535
Left = 6240
TabIndex = 1
Top = 240
Width = 3975
Begin VB.TextBox Text8
Height = 495
Left = 1440
TabIndex = 19
Top = 4320
Width = 1935
End
Begin VB.TextBox Text7
Height = 495
Left = 1440
TabIndex = 18
Top = 3480
Width = 1335
End
Begin VB.TextBox Text6
Height = 495
Left = 1440
TabIndex = 17
Top = 2640
Width = 1095
End
Begin VB.TextBox Text5
Height = 495
Left = 1440
TabIndex = 16
Top = 1800
Width = 975
End
Begin VB.TextBox Text4
Height = 495
Left = 1440
TabIndex = 15
Top = 1080
Width = 1815
End
Begin VB.TextBox Text3
Height = 495
Left = 1440
TabIndex = 14
Top = 240
Width = 1815
End
Begin VB.Label Label8
Caption = "電話"
Height = 615
Left = 120
TabIndex = 13
Top = 4440
Width = 1215
End
Begin VB.Label Label7
Caption = "所屬院系"
Height = 615
Left = 120
TabIndex = 12
Top = 3480
Width = 1215
End
Begin VB.Label Label6
Caption = "年齡"
Height = 495
Left = 120
TabIndex = 11
Top = 2760
Width = 1215
End
Begin VB.Label Label5
Caption = "性別"
Height = 615
Left = 120
TabIndex = 10
Top = 1920
Width = 1215
End
Begin VB.Label Label4
Caption = "學生學號(若要修改輸入則必添)"
Height = 615
Left = 120
TabIndex = 9
Top = 1080
Width = 1215
End
Begin VB.Label Label3
Caption = "學生姓名"
Height = 495
Left = 120
TabIndex = 8
Top = 360
Width = 1215
End
End
Begin VB.Frame Frame1
Caption = "查詢輸入(兩者選擇一個或兩個都可)"
Height = 1935
Left = 240
TabIndex = 0
Top = 240
Width = 5775
Begin VB.CommandButton Command1
Caption = "查詢"
Height = 495
Left = 4800
TabIndex = 6
Top = 1200
Width = 855
End
Begin VB.TextBox Text2
Height = 495
Left = 2400
TabIndex = 5
Top = 1080
Width = 1455
End
Begin VB.TextBox Text1
Height = 495
Left = 360
TabIndex = 4
Top = 1080
Width = 1215
End
Begin VB.Label Label2
Caption = "學生學號"
Height = 495
Left = 2400
TabIndex = 3
Top = 480
Width = 1335
End
Begin VB.Label Label1
Caption = "學生姓名"
Height = 495
Left = 360
TabIndex = 2
Top = 480
Width = 1215
End
End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim str As String
Dim i As Integer
Set cn = New ADODB.Connection
cn.ConnectionString = "driver={sql server};server=fu;uid=sa;pwd=;database=sinformation"
cn.Open
Set rs = New ADODB.Recordset
If Text1.Text = "" Then
If Text2.Text = "" Then
txtsql = "select * from student"
Else
txtsql = "select * from student where 學生學號='" + Text2.Text + "'"
End If
Else
If Text2.Text = "" Then
txtsql = "select * from student where 學生姓名='" + Text1.Text + "'"
Else
txtsql = "select * from student where 學生姓名='" + Text1.Text + "' and 學生學號='" + Text2.Text + "'"
End If
End If
rs.Open txtsql, cn, adOpenDynamic, adLockOptimistic
If rs.EOF Then
MsgBox "沒有找到任何相關記錄", , "提示"
With MSFlexGrid1
.Cols = 0
.Rows = 0
End With
Else
With MSFlexGrid1
.Cols = 6
.Rows = 1
For i = 0 To 5
.TextMatrix(0, i) = rs.Fields(i).Name
Next i
While Not rs.EOF
.Rows = .Rows + 1
For i = 0 To 5
.TextMatrix(.Rows - 1, i) = rs.Fields(i)
Next i
rs.movenext
Wend
End With
End If
End Sub
Private Sub Command2_Click()
Set cn = New ADODB.Connection
cn.ConnectionString = "driver={sql server};server=fu;uid=sa;pwd=;database=sinformation"
cn.Open
Set rs = New ADODB.Recordset
txtsql = "select * from student where 學生學號='" + Text4.Text + "'"
rs.Open txtsql, cn, adOpenDynamic, adLockOptimistic
rs.Fields(0) = Text3.Text
rs.Fields(1) = Text4.Text
rs.Fields(2) = Text5.Text
rs.Fields(3) = Text6.Text
rs.Fields(4) = Text7.Text
rs.Fields(5) = Text8.Text
rs.Update
rs.Close
MsgBox "修改成功", , "提示"
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
txtsql = "select * from student"
rs.Open txtsql, cn, adOpenDynamic, adLockOptimistic
If rs.EOF Then
MsgBox "沒有找到任何相關記錄", , "提示"
With MSFlexGrid1
.Cols = 0
.Rows = 0
End With
Else
With MSFlexGrid1
.Cols = 6
.Rows = 1
For i = 0 To 5
.TextMatrix(0, i) = rs.Fields(i).Name
Next i
While Not rs.EOF
.Rows = .Rows + 1
For i = 0 To 5
.TextMatrix(.Rows - 1, i) = rs.Fields(i)
Next i
rs.movenext
Wend
End With
End If
End Sub
Private Sub Command3_Click()
Form3.Hide
Form1.Show
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -