📄 frm_calling_card_add.frm
字号:
VERSION 5.00
Begin VB.Form Frm_Calling_Card_Add
BorderStyle = 1 'Fixed Single
Caption = "名片添加"
ClientHeight = 3615
ClientLeft = 45
ClientTop = 330
ClientWidth = 3195
Icon = "Frm_Calling_Card_Add.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3615
ScaleWidth = 3195
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command2
Cancel = -1 'True
Caption = "取消"
Height = 375
Left = 1740
TabIndex = 13
Top = 3060
Width = 975
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 375
Left = 420
TabIndex = 12
Top = 3060
Width = 975
End
Begin VB.TextBox Text6
Height = 540
Left = 900
MultiLine = -1 'True
TabIndex = 11
Top = 2340
Width = 2055
End
Begin VB.TextBox Text5
Height = 300
Left = 900
TabIndex = 9
Top = 1920
Width = 2055
End
Begin VB.TextBox Text4
Height = 300
Left = 900
TabIndex = 7
Top = 1500
Width = 2055
End
Begin VB.TextBox Text3
Height = 300
Left = 900
TabIndex = 5
Top = 1080
Width = 2055
End
Begin VB.TextBox Text2
Height = 300
Left = 900
TabIndex = 3
Top = 660
Width = 2055
End
Begin VB.TextBox Text1
Height = 300
Left = 900
TabIndex = 1
Top = 240
Width = 2055
End
Begin VB.Label Label6
Caption = "地址"
Height = 300
Left = 240
TabIndex = 10
Top = 2340
Width = 555
End
Begin VB.Label Label5
Caption = "手机"
Height = 300
Left = 240
TabIndex = 8
Top = 1920
Width = 555
End
Begin VB.Label Label4
Caption = "电话"
Height = 300
Left = 240
TabIndex = 6
Top = 1500
Width = 555
End
Begin VB.Label Label3
Caption = "职务"
Height = 300
Left = 240
TabIndex = 4
Top = 1080
Width = 555
End
Begin VB.Label Label2
Caption = "公司"
Height = 300
Left = 240
TabIndex = 2
Top = 660
Width = 555
End
Begin VB.Label Label1
Caption = "姓名"
Height = 300
Left = 240
TabIndex = 0
Top = 300
Width = 555
End
End
Attribute VB_Name = "Frm_Calling_Card_Add"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
On Error GoTo myerr
Dim cn As ADODB.Connection
Dim rst As New ADODB.Recordset
If Trim(Text1) = "" Then
MsgBox "姓名不能为空!", vbExclamation, "提示"
Text1.SetFocus
Exit Sub
End If
If Trim(Text2) = "" Then
MsgBox "公司不能为空!", vbExclamation, "提示"
Text2.SetFocus
Exit Sub
End If
If Trim(Text3) = "" Then
MsgBox "职务不能为空!", vbExclamation, "提示"
Text3.SetFocus
Exit Sub
End If
If Trim(Text4) = "" Then
MsgBox "电话不能为空!", vbExclamation, "提示"
Text4.SetFocus
Exit Sub
End If
If Trim(Text5) = "" Then
MsgBox "手机不能为空!", vbExclamation, "提示"
Text5.SetFocus
Exit Sub
End If
If Trim(Text6) = "" Then
MsgBox "地址不能为空!", vbExclamation, "提示"
Text6.SetFocus
Exit Sub
End If
If Len(Text1) > 8 Then
MsgBox "姓名超长!", vbExclamation, "提示"
Text1.SetFocus
Exit Sub
End If
If Len(Text2) > 100 Then
MsgBox "公司名超长!", vbExclamation, "提示"
Text2.SetFocus
Exit Sub
End If
If Len(Text3) > 50 Then
MsgBox "职务超长!", vbExclamation, "提示"
Text3.SetFocus
Exit Sub
End If
If Len(Text4) > 20 Then
MsgBox "电话超长!", vbExclamation, "提示"
Text4.SetFocus
Exit Sub
End If
If Len(Text5) > 20 Then
MsgBox "手机超长!", vbExclamation, "提示"
Text5.SetFocus
Exit Sub
End If
If Len(Text6) > 200 Then
MsgBox "地址超长!", vbExclamation, "提示"
Text6.SetFocus
Exit Sub
End If
Set cn = GetCn
rst.Open "select * from calling_card where name='" & Trim(Text1) & "'", cn, 0, 1
If Not (rst.BOF And rst.EOF) Then
If MsgBox("该姓名已存在,是否继续保存?", vbYesNo + vbQuestion, "提示") = vbNo Then Exit Sub
End If
cn.Execute "insert into calling_card (name,inc,duty,phone,handset,addrs) values ('" & Trim(Text1) & "','" & Trim(Text2) & "','" & Trim(Text3) & "','" & Trim(Text4) & "','" & Trim(Text5) & "','" & Trim(Text6) & "')"
MsgBox "保存成功!", vbExclamation, "提示"
Unload Me
Exit Sub
myerr:
MsgBox Error, vbExclamation, "提示"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -