📄 form_tongxun.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form Form_Tongxun
Caption = "通讯录"
ClientHeight = 5220
ClientLeft = 60
ClientTop = 435
ClientWidth = 9495
LinkTopic = "Form1"
ScaleHeight = 5220
ScaleWidth = 9495
StartUpPosition = 3 '窗口缺省
Begin MSAdodcLib.Adodc Adodc_tx
Height = 495
Left = 5160
Top = 2640
Visible = 0 'False
Width = 1215
_ExtentX = 2143
_ExtentY = 873
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 3
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "DSN=database"
OLEDBString = ""
OLEDBFile = ""
DataSourceName = "database"
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select * from tongxun"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Frame Frame1
Height = 4815
Left = 120
TabIndex = 0
Top = 120
Width = 9255
Begin VB.ComboBox Cmb_sex
DataSource = "Adodc_tx"
Height = 300
ItemData = "Form_Tongxun.frx":0000
Left = 720
List = "Form_Tongxun.frx":000A
TabIndex = 16
Top = 840
Width = 1695
End
Begin VB.TextBox Text5
DataSource = "Adodc_tx"
Height = 975
Left = 720
TabIndex = 15
Top = 3000
Width = 1695
End
Begin VB.TextBox Text4
DataSource = "Adodc_tx"
Height = 375
Left = 720
TabIndex = 14
Top = 2520
Width = 1695
End
Begin VB.TextBox Text3
DataSource = "Adodc_tx"
Height = 375
Left = 720
TabIndex = 13
Top = 2040
Width = 1695
End
Begin VB.TextBox Text2
DataSource = "Adodc_tx"
Height = 390
Left = 720
TabIndex = 12
Top = 1440
Width = 1695
End
Begin VB.TextBox Text1
DataSource = "Adodc_tx"
Height = 375
Left = 720
TabIndex = 11
Top = 240
Width = 1695
End
Begin VB.CommandButton Cmd_exit
Caption = "退出"
Height = 375
Left = 1800
TabIndex = 10
Top = 4200
Width = 735
End
Begin VB.CommandButton Cmd_delete
Caption = "删除"
Height = 375
Left = 960
TabIndex = 9
Top = 4200
Width = 735
End
Begin VB.CommandButton Cmd_save
Caption = "添加"
Height = 375
Left = 120
TabIndex = 8
Top = 4200
Width = 735
End
Begin MSDataGridLib.DataGrid DataGrid_tx
Bindings = "Form_Tongxun.frx":0016
Height = 4335
Left = 2760
TabIndex = 7
Top = 240
Width = 6375
_ExtentX = 11245
_ExtentY = 7646
_Version = 393216
AllowUpdate = -1 'True
HeadLines = 1
RowHeight = 15
AllowAddNew = -1 'True
AllowDelete = -1 'True
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Caption = "通讯录列表"
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
Begin VB.Line Line2
X1 = 0
X2 = 2640
Y1 = 4080
Y2 = 4080
End
Begin VB.Line Line1
X1 = 2640
X2 = 2640
Y1 = 120
Y2 = 4680
End
Begin VB.Label Label6
Caption = "备注:"
Height = 255
Left = 120
TabIndex = 6
Top = 3240
Width = 615
End
Begin VB.Label Label5
Caption = "电话:"
Height = 255
Left = 120
TabIndex = 5
Top = 2640
Width = 615
End
Begin VB.Label Label4
Caption = "地址:"
Height = 255
Left = 120
TabIndex = 4
Top = 2040
Width = 615
End
Begin VB.Label Label3
Caption = "年龄:"
Height = 255
Left = 120
TabIndex = 3
Top = 1560
Width = 615
End
Begin VB.Label Label2
Caption = "性别:"
Height = 255
Left = 120
TabIndex = 2
Top = 960
Width = 615
End
Begin VB.Label Label1
Caption = "姓名:"
Height = 375
Left = 120
TabIndex = 1
Top = 360
Width = 615
End
End
End
Attribute VB_Name = "Form_Tongxun"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Cmd_exit_Click()
Unload Me
End Sub
Private Sub Cmd_save_Click() '添加一个通讯记录
Dim sqlstr As String
If Me.Text1.Text = "" Or Me.Cmb_sex.Text = "" Or _
Me.Text2.Text = "" Or Me.Text3.Text = "" Or _
Me.Text4.Text = "" Then
MsgBox "不能空白!"
Exit Sub
End If
On Error Resume Next
'添加一个通讯记录到数据库
sqlstr = "insert into tongxun" & "(name,sex,age,address,telephone,beizhu)" & _
"values(" & "'" & Me.Text1.Text & "'," & _
"'" & Me.Cmb_sex.Text & "'," & _
"'" & Me.Text2.Text & "'," & _
"'" & Me.Text3.Text & "'," & _
"'" & Me.Text4.Text & "'," & _
"'" & Me.Text5.Text & "');"
RemoteCnn.Execute sqlstr
MsgBox "添加成功!"
'界面更新
Me.Adodc_tx.Refresh
End Sub
Private Sub Cmd_delete_Click() '删除一个通讯记录
'是否选择了记录
If Me.DataGrid_tx.Row = -1 Then
MsgBox "没有数据"
Exit Sub
End If
'删除一个选定的记录
Me.Adodc_tx.Recordset.Delete
MsgBox "删除成功"
End Sub
Private Sub DataGrid_tx_Click() '选择一个通讯记录
'在界面显示选定的记录
Me.Text1.Text = DataGrid_tx.Columns(1).Text
Me.Cmb_sex.Text = DataGrid_tx.Columns(2).Text
Me.Text2.Text = DataGrid_tx.Columns(3).Text
Me.Text3.Text = DataGrid_tx.Columns(4).Text
Me.Text4.Text = DataGrid_tx.Columns(5).Text
Me.Text5.Text = DataGrid_tx.Columns(6).Text
End Sub
Private Sub Form_Load() '窗体装载
On Error Resume Next
'打开通讯录表并填充表格
Me.Adodc_tx.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=" & _
"False;User ID=" & UID & ";pwd=" & PWD & ";Data Source=" & MyDSN
Adodc_tx.RecordSource = "select ID as 编号," & _
"name as 姓名," & _
"sex as 性别," & _
"address as 地址," & _
"telephone as 电话," & _
"beizhu as 备注 from tongxun"
Adodc_tx.Refresh
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -