?? form2.frm
字號:
VERSION 5.00
Begin VB.Form Form2
Caption = "學生記錄添加\刪除"
ClientHeight = 5055
ClientLeft = 60
ClientTop = 450
ClientWidth = 6405
LinkTopic = "Form2"
ScaleHeight = 5055
ScaleWidth = 6405
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "取消"
Height = 495
Left = 3240
TabIndex = 11
Top = 3600
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "確定"
Height = 495
Left = 1080
TabIndex = 10
Top = 3600
Width = 1215
End
Begin VB.TextBox Text4
Height = 375
Left = 1200
TabIndex = 9
Top = 2520
Width = 1455
End
Begin VB.TextBox Text3
Height = 375
Left = 4080
TabIndex = 8
Top = 1440
Width = 1335
End
Begin VB.ComboBox Combo1
Height = 300
ItemData = "Form2.frx":0000
Left = 1320
List = "Form2.frx":000A
TabIndex = 7
Top = 1440
Width = 1335
End
Begin VB.TextBox Text2
Height = 375
Left = 4080
TabIndex = 6
Top = 480
Width = 1335
End
Begin VB.TextBox Text1
Height = 375
Left = 1320
TabIndex = 5
Top = 480
Width = 1335
End
Begin VB.Label Label5
Caption = "系別:"
Height = 375
Left = 120
TabIndex = 4
Top = 2520
Width = 855
End
Begin VB.Label Label4
Caption = "年齡:"
Height = 375
Left = 3120
TabIndex = 3
Top = 1440
Width = 615
End
Begin VB.Label Label3
Caption = "性別:"
Height = 375
Left = 120
TabIndex = 2
Top = 1440
Width = 735
End
Begin VB.Label Label2
Caption = "姓名:"
Height = 255
Left = 3120
TabIndex = 1
Top = 480
Width = 735
End
Begin VB.Label Label1
Caption = "學號:"
Height = 255
Left = 240
TabIndex = 0
Top = 480
Width = 735
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim sql As String
Dim a As String
sql = "select Sno from student where Sno='20060002'" '查詢條件'
a = 20060002
If sql = a Then
MsgBox ("輸入的學號相同!請從新輸入")
Else
If Form1.cmdadd.Enabled = True Then
Form1.Adodc1.Recordset.AddNew '添加一條新記錄
Else
Form1.Adodc1.Recordset.Update '將修改的記錄保存在數據庫中
End If
'將結果集相應的字段寫到文本框中
Form1.Adodc1.Recordset.Fields("Sno") = Trim(Text1.Text)
Form1.Adodc1.Recordset.Fields("Sname") = Trim(Text2.Text)
Form1.Adodc1.Recordset.Fields("Ssex") = Trim(Combo1.Text)
Form1.Adodc1.Recordset.Fields("Sage") = CInt(Trim(Text3.Text))
Form1.Adodc1.Recordset.Fields("Sdept") = Trim(Text4.Text)
Text1.Text = ""
Text2.Text = ""
Combo1.Text = ""
Text3.Text = ""
Text4.Text = ""
End If
End Sub
Private Sub Command2_Click()
Form2.Visible = False
Form1.CmdUpdate.Enabled = True
Form1.cmdadd.Enabled = True
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -