【VB开源代码栏目提醒】:网学会员为广大网友收集整理了,type_delete.frm,希望对大家有所帮助!
VERSION 5.00
Begin VB.Form Form12
Caption = "类别删除"
ClientHeight = 4635
ClientLeft = 60
ClientTop = 345
ClientWidth = 5700
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form12"
ScaleHeight = 4635
ScaleWidth = 5700
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command2
Caption = "取消"
Height = 495
Left = 3120
TabIndex = 5
Top = 3720
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "删除"
Height = 495
Left = 1200
TabIndex = 4
Top = 3720
Width = 1215
End
Begin VB.TextBox Text1
Enabled = 0 'False
Height = 1455
Left = 2520
MultiLine = -1 'True
TabIndex = 3
Top = 1680
Width = 2295
End
Begin VB.ComboBox Combo1
Height = 330
Left = 2520
Style = 2 'Dropdown List
TabIndex = 1
Top = 360
Width = 2295
End
Begin
VB.Label Label2
Caption = "说 明:"
Height = 495
Left = 600
TabIndex = 2
Top = 1680
Width = 1455
End
Begin VB.Label Label1
Caption = "选择类别名:"
Height = 495
Left = 600
TabIndex = 0
Top = 360
Width = 1455
End
End
Attribute VB_Name = "Form12"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Combo1_Click()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
Dim str As String
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\file.mdb;Persist Security Info=False"
str = Combo1.Text
sql = "select * from typeinfo where tname='" & str & "'"
rs.Open sql, cn, 1, 1
Text1.Text = rs("tmemo")
End Sub
Private Sub Command1_Click()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
Dim tname As String
tname = Trim(Combo1.Text)
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\file.mdb;Persist Security Info=False"
sql = "select * FROM typeinfo where tname= '" & tname & "'"
rs.Open sql, cn, 3, 2
response = MsgBox("确定要删除此类别吗?删除后不可恢复", vbOKCancel + 32, "提示")
If response = vbOK Then
rs.Delete
MsgBox "类别删除成功"
Combo1.Refresh
End If
End Sub
Private Sub Form_Load()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\file.mdb;Persist Security Info=False"
sql = "select * FROM typeinfo "
rs.Open sql, cn, 1, 1
Do While rs.EOF <> True
Combo1.AddItem rs("tname")
rs.MoveNext
Loop
End Sub