永发信息网

VB通讯录代码

答案:1  悬赏:20  手机版
解决时间 2021-05-08 06:39
VB做的通讯薄代码。要微软自带的那种,最好把FORM一起传上来!!
最佳答案



Public panduan As Integer
Private Sub Combo1_Click()
Data1.Recordset.MoveFirst
Data1.Recordset.FindFirst "姓名='" & Combo1.Text & "'"
Call xianshi
End Sub


Private Sub Combo2_Click()
Data2.Recordset.MoveLast
Data2.Recordset.FindLast "时间='" & Combo2.Text & "'"
Call xianshi2
End Sub


Private Sub Command1_Click()
If Data1.Recordset.AbsolutePosition = Data1.Recordset.RecordCount - 1 Then
MsgBox "已经到最后一条记录", 0 + 16, "警告"
Exit Sub
Else
Data1.Recordset.MoveNext
Combo1.Text = Data1.Recordset("姓名")
Call xianshi
End If
End Sub


Private Sub Command10_Click()
If Command10.Caption = "写日记" Then
Text11.Text = ""
Combo2.Text = Text12.Text
Command10.Caption = "保存"
Else

With Data2
.Recordset.AddNew


.Recordset("时间") = Text12
.Recordset("事件") = Text11
.Recordset.Update
End With
Combo2.Clear
Data2.Refresh
Call chushihua2
Call xianshi2
Command10.Caption = "写日记"
End If
End Sub


Private Sub Command11_Click()
a = MsgBox("当前记录将被删除,确定吗?", 4 + 48, "警告")
If a = vbNo Then Exit Sub
Data2.Recordset.Delete
Data2.Refresh
Combo2.Clear
Call chushihua2
End Sub


Private Sub Command12_Click()
Data2.Recordset.MoveLast
Combo2.Text = Data2.Recordset("时间")
Call xianshi2
End Sub


Private Sub Command13_Click()
If Data2.Recordset.AbsolutePosition = 0 Then
MsgBox "这已经是最为古老的日记了", 0 + 16, ""
Exit Sub
Else
Data2.Recordset.MovePrevious
Combo2.Text = Data2.Recordset("时间")
Call xianshi2
End If
End Sub


Private Sub Command14_Click()
If Data2.Recordset.AbsolutePosition = Data2.Recordset.RecordCount - 1 Then
MsgBox "这已经是最新的一篇了", 0 + 16, "警告"
Exit Sub
Else
Data2.Recordset.MoveNext
Combo2.Text = Data2.Recordset("时间")
Call xianshi2
End If
End Sub


Private Sub Command2_Click()
panduan = 1
If Command2.Caption = "添加" Then
Command1.Enabled = False
Command3.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
Command2.Caption = "保存数据"
Text2.Visible = True
Text3.Visible = True
Text4.Visible = True
Text5.Visible = True
Text6.Visible = True
Text7.Visible = True
Text8.Visible = True
Text9.Visible = True
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""


Else
If Text8.Text = "" Then
MsgBox "请输入完整数据!", 48, "警告"
Text8.SetFocus



Else
a = MsgBox("当前记录将被添加,确定吗?", 4 + 48, "警告")
If a = vbNo Then
Command2.Caption = "添加"
Command1.Enabled = True
Command3.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Text2.Visible = False
Text3.Visible = False
Text4.Visible = False
Text5.Visible = False
Text6.Visible = False
Text7.Visible = False
Text8.Visible = False
Text9.Visible = False
Exit Sub


Else
Command2.Caption = "添加"
Command1.Enabled = True
Command3.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Data1.Recordset.Edit
With Data1
.Recordset.AddNew
.Recordset("姓名") = Text8.Text
.Recordset("手机号") = Text2
.Recordset("性别") = Text3
.Recordset("工作单位") = Text4
.Recordset("职务") = Text5
.Recordset("电子邮箱") = Text6
.Recordset("联系地址") = Text7
.Recordset("QQ") = Text9
End With
Command2.Caption = "添加"
Text2.Visible = False
Text3.Visible = False
Text4.Visible = False
Text5.Visible = False
Text6.Visible = False
Text7.Visible = False
Text8.Visible = False
Text9.Visible = False
Combo1.Clear
Data1.Refresh
Call chushihua
Call xianshi
End If
End If
End If
End Sub


Private Sub Command3_Click()
If Command3.Caption = "修改" Then
Command1.Enabled = False
Command2.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
Command3.Caption = "保存修改"
Text2.Visible = True
Text3.Visible = True
Text4.Visible = True
Text5.Visible = True
Text6.Visible = True
Text7.Visible = True
Text8.Visible = True
Text9.Visible = True


Text2.Text = Label12.Caption
Text3.Text = Label13.Caption
Text4.Text = Label14.Caption
Text5.Text = Label15.Caption
Text6.Text = Label16.Caption
Text7.Text = Label17.Caption
Text8.Text = Combo1.Text
Text9.Text = Label18.Caption
Else
If Text8.Text = "" Then
MsgBox "请输入完整数据!", 48
Text8.SetFocus


Else
a = MsgBox("当前记录将被修改,确定吗?", 4 + 48, "警告")
If a = vbNo Then
Command3.Caption = "修改"
Command1.Enabled = True
Command2.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Text2.Visible = False
Text3.Visible = False
Text4.Visible = False
Text5.Visible = False
Text6.Visible = False
Text7.Visible = False
Text8.Visible = False
Text9.Visible = False
Exit Sub
Else
Command3.Caption = "修改"
Command1.Enabled = True
Command2.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Data1.Recordset.Edit
With Data1
.Recordset("姓名") = Text8.Text
.Recordset("手机号") = Text2
.Recordset("性别") = Text3
.Recordset("工作单位") = Text4
.Recordset("职务") = Text5
.Recordset("电子邮箱") = Text6
.Recordset("联系地址") = Text7
.Recordset("QQ") = Text9
End With
Command3.Caption = "修改"
Text2.Visible = False
Text3.Visible = False
Text4.Visible = False
Text5.Visible = False
Text6.Visible = False
Text7.Visible = False
Text8.Visible = False
Text9.Visible = False
Combo1.Clear
Data1.Refresh
Call chushihua
Call xianshi
End If
End If
End If
End Sub


Private Sub Command4_Click()
If Command3.Caption = "保存修改" Or Command2.Caption = "保存数据" Then
Command3.Caption = "修改"
Command2.Caption = "添加"
Text2.Visible = False
Text3.Visible = False
Text4.Visible = False
Text5.Visible = False
Text6.Visible = False
Text7.Visible = False
Text8.Visible = False
Text9.Visible = False
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Combo1.Clear
Data1.Refresh
Call chushihua
Call xianshi
Else


End
End If
End Sub


Private Sub Command5_Click()
a = MsgBox("当前记录将被删除,确定吗?", 4 + 48, "警告")
If a = vbNo Then Exit Sub
Data1.Recordset.Delete
Data1.Refresh
Combo1.Clear
Call chushihua
End Sub



Private Sub Command6_Click()
If Data1.Recordset.AbsolutePosition = 0 Then
MsgBox "已经到达第一条了", 0 + 16, ""
Exit Sub
Else
Data1.Recordset.MovePrevious
Combo1.Text = Data1.Recordset("姓名")
Call xianshi
End If
End Sub


Private Sub Command7_Click()
Data1.Recordset.MoveFirst
Combo1.Text = Data1.Recordset("姓名")
Call xianshi
End Sub


Private Sub Command8_Click()
Data1.Recordset.MoveLast
Combo1.Text = Data1.Recordset("姓名")
Call xianshi
End Sub


Private Sub Command9_Click()
Data1.Recordset.MoveFirst
Data1.Recordset.FindFirst "手机号='" & Text10.Text & "'"
Combo1.Text = Data1.Recordset("姓名")
If Data1.Recordset.NoMatch Then
MsgBox "查无此人!", 48, "注意"
Else


Call xianshi
End If
Call xianshi
End Sub


Private Sub Form_Initialize()
Data1.Refresh
Data2.Refresh
Call chushihua
Call chushihua2
End Sub
Sub gengxin()
Data1.Recordset.MoveFirst
Data1.Recordset.Update
Data1.Recordset.Edit
End Sub
Sub chushihua()
Data1.Recordset.MoveFirst


Do While Data1.Recordset.EOF = False
Combo1.AddItem Data1.Recordset("姓名")


Data1.Recordset.MoveNext
Loop
jlzs = Data1.Recordset.RecordCount
Text1.Text = jlzs
Data1.Recordset.MoveFirst
Combo1.Text = Data1.Recordset("姓名")


Call xianshi
End Sub


Private Sub Form_Load()
Data1.DatabaseName = "db1.mdb"
Data2.DatabaseName = "db2.mdb"
Data1.RecordSource = "表2"
Data2.RecordSource = "表1"
Dim jlzs As Integer


End Sub
Private Sub Combo1_keyup(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Data1.Recordset.MoveFirst
Data1.Recordset.FindFirst "姓名='" & Combo1.Text & "'"
Combo1.Text = Data1.Recordset("姓名")
If Data1.Recordset.NoMatch Then
MsgBox "查无此人!", 48, "注意"
Else


Call xianshi
End If
End If
End Sub


Sub xianshi()


Label8.Caption = "当前记录号:" & Data1.Recordset.AbsolutePosition + 1
End Sub
Sub xianshi2()
Text11 = Data2.Recordset("事件")
End Sub


Sub chushihua2()
Data2.Recordset.MoveFirst


Do While Data2.Recordset.EOF = False
Combo2.AddItem Data2.Recordset("时间")
Text11 = Data2.Recordset("事件")
Data2.Recordset.MoveNext
Loop


Data2.Recordset.MoveFirst
Combo2.Text = Data2.Recordset("时间")
Text11 = Data2.Recordset("事件")
Call xianshi
End Sub



Private Sub Text10_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Data1.Recordset.MoveFirst
Data1.Recordset.FindFirst "手机号='" & Text10.Text & "'"
Combo1.Text = Data1.Recordset("姓名")
If Data1.Recordset.NoMatch Then
MsgBox "查无此人!", 48, "注意"
Else


Call xianshi
End If
End If
End Sub



Private Sub Timer1_Timer()
If Label19.Left + Label19.Width > 0 Then
Label19.Move Label19.Left - 20
Else
Label19.Left = Form1.ScaleWidth
End If
End Sub


Private Sub Timer2_Timer()
Text12.Text = Now
End Sub


我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
win7玩gta4
浪漫满屋的插曲有一首歌曲在劲舞中有!谁知道
想申请个YY怎么办
加油站属于什么建筑,加油站站房属于什么建筑
我想戒了爱!如果可能的话……
N97降价了么
一波建筑空间设计制作公司在什么地方啊,我要
古筝倍高音换弦多少钱,求助,自家古筝断弦了
江西联通发短信开通GPRS方法,拜托一定要详细
上海电视大学教育质量怎样???
我想改名,现在征集名字!(四个字的)我姓张
支原体依原体要几个疗程能治渝
四川成都飞往广西南宁的飞机票现在是多少?
**有臭鱼味是怎么回事啊
老婆精神出轨怎么办,感觉自己精神出轨了,怎
推荐资讯
大众酒家地址在哪,我要去那里办事
我的弟弟是恶魔
为什么自己的QQ会在自己的Q里面
什么牌子隐形眼镜好,隐形车衣哪个品牌好?
帮忙写个自我介绍。 她是学习播音主持的。基
不用卷发棒怎么做内扣,怎样让烫过的头发保持
描写打鼓声优美的句子,(2014?黄冈)端午节赛
终极三国里面的主要人物是谁
吉林2紫云犀角棍可以买多少钱
诛仙2 55—70 可接任务
为什么?有人在上网时不喜欢玩游戏呢?
大众谁最红
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?