【VB开源代码栏目提醒】:以下是网学会员为您推荐的VB开源代码-type_insert.frm,希望本篇文章对您学习有所帮助。
VERSION 5.00
Begin VB.Form Form11
Caption = "类别添加"
ClientHeight = 3840
ClientLeft = 60
ClientTop = 345
ClientWidth = 5310
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form11"
ScaleHeight = 3840
ScaleWidth = 5310
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox Text2
Height = 1335
Left = 1920
MultiLine = -1 'True
TabIndex = 5
Text = "type_insert.frx":0000
Top = 1200
Width = 2535
End
Begin VB.CommandButton Command2
Caption = "关闭"
Height = 495
Left = 2880
TabIndex = 4
Top = 2760
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 495
Left = 960
TabIndex = 3
Top = 2760
Width = 975
End
Begin VB.TextBox Text1
Height = 375
Left = 1920
TabIndex = 1
Text = "Text1"
Top = 480
Width = 2535
End
Begin
VB.Label Label2
Caption = "说 明:"
Height = 375
Left = 480
TabIndex = 2
Top = 1200
Width = 1215
End
Begin VB.Label Label1
Caption = "类别名称:"
Height = 495
Left = 480
TabIndex = 0
Top = 480
Width = 1215
End
End
Attribute VB_Name = "Form11"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\file.mdb;Persist Security Info=False"
If Trim(Text1.Text) = "" Then
MsgBox "类别名称不能为空"
Else
sql = "select * from typeinfo where tname='" & Text1.Text & "'"
rs.Open
sql, cn, 3, 2
If rs.EOF = False Then
MsgBox "该类别名称已存在,请重新输入"
Else
rs.AddNew
rs("tname") = Text1.Text
rs("tmemo") = Text2.Text
rs.Update
MsgBox "添加成功"
End If
End If
End Sub