www.pudn.com > myActivebart.rar > subject.frm
VERSION 5.00
Begin VB.Form Form13
Caption = "科目"
ClientHeight = 4305
ClientLeft = 60
ClientTop = 345
ClientWidth = 4305
Icon = "subject.frx":0000
LinkTopic = "Form13"
ScaleHeight = 4305
ScaleWidth = 4305
StartUpPosition = 2 '屏幕中心
Begin VB.ListBox List1
BackColor = &H00FFFFFF&
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 2940
Left = 300
TabIndex = 6
Top = 600
Width = 3825
End
Begin VB.CommandButton Command2
Caption = "修改(&M)"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 1440
TabIndex = 5
Top = 3780
Width = 915
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 345
Left = 1020
TabIndex = 3
Top = 150
Width = 3075
End
Begin VB.CommandButton Command1
Caption = "添加(&A)"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 540
TabIndex = 2
Top = 3780
Width = 915
End
Begin VB.CommandButton Command3
Caption = "删除(&D)"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 2340
TabIndex = 1
Top = 3780
Width = 915
End
Begin VB.CommandButton Command4
Caption = "退出(&D)"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 3240
TabIndex = 0
Top = 3780
Width = 915
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "科目:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 360
TabIndex = 4
Top = 210
Width = 570
End
End
Attribute VB_Name = "Form13"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs As New ADODB.Recordset
Private Sub Command1_Click()
On Error GoTo error:
If Text1.Text = "" Then
Exit Sub
End If
If rs.State = 1 Then rs.Close
rs.Open "select 科目 from 科目表", cnn, adOpenKeyset, adLockPessimistic
rs.MoveLast
rs.AddNew
rs.Fields("科目") = Text1.Text
rs.Update
additem
Exit Sub
error:
MsgBox (Err.Description)
Exit Sub
End Sub
Private Sub Command2_Click()
On Error GoTo error:
If Text1.Text = "" Then
Exit Sub
End If
If rs.State = 1 Then rs.Close
rs.Open "update 科目表 set 科目= " & "'" & Text1.Text & "' where 科目= " & "'" & List1.List(List1.ListIndex) & "'", cnn, adOpenKeyset, adLockPessimistic
additem
Exit Sub
error:
MsgBox (Err.Description)
Exit Sub
End Sub
Private Sub Command3_Click()
If MsgBox("您是否真的要删除", vbYesNo + vbQuestion, "提示") = vbYes Then
If rs.State = 1 Then rs.Close
rs.Open "delete from 科目表 where 科目 = " & "'" & List1.List(List1.ListIndex) & "'", cnn, adOpenKeyset, adLockPessimistic
additem
End If
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub additem()
If rs.State = 1 Then rs.Close
rs.Open "select 科目 from 科目表", cnn, adOpenKeyset, adLockPessimistic
List1.Clear
If rs.RecordCount <> 0 Then
Do While Not rs.EOF
List1.additem rs.Fields("科目")
rs.MoveNext
Loop
Text1.Text = ""
End If
End Sub
Private Sub Form_Load()
additem
End Sub