用vb做一个通讯录管理系统
1》设计一个功能菜单;2》定义通讯录记录类型,并定义记录类型数组,建立通讯录数据,包括姓名、单位、电话;3》能实现信息的输入、浏览、查找、增加、删除、修改、排序;4》通讯...
1》设计一个功能菜单;
2》定义通讯录记录类型,并定义记录类型数组,建立通讯录数据,包括姓名、单位、电话;
3》能实现信息的输入、浏览、查找、增加、删除、修改、排序;
4》通讯录数据信息包括姓名、单位、电话,都应该保存在文件里。 展开
2》定义通讯录记录类型,并定义记录类型数组,建立通讯录数据,包括姓名、单位、电话;
3》能实现信息的输入、浏览、查找、增加、删除、修改、排序;
4》通讯录数据信息包括姓名、单位、电话,都应该保存在文件里。 展开
2个回答
展开全部
如果你平时有许多同学和朋友的信息,试试在计算机上编写一个我这样的通讯录。非常方便的哟。 先新建一个工程,在“工具箱->右键->部件”添加“Microsoft windows common control 6.0”,然后在窗体上添加五个标签,“标题”分别为 “姓名、电话、Oicq、E-Mail、地址”;添加一个文本框(text1), 然后[复制/粘贴4次]使其成为控件数组;添加一个Listview控件(Listview1),在其属性框中,添加五个“列首”,“文本”值分别为“姓名、电话、Oicq、E-Mail、地址”,“查看属性”为 “3-lvwReport”, 选中“整行选择”,取消“隐藏选择”;添加两个按钮,其标题属性分别为“添加”、“删除”。添加如下代码:
Option Explicit
Dim fileName As String
Private Sub Command1_Click()
’将文本框中的信息添加到列表框中
Dim i As Integer
With ListView1.ListItems.Add()
.Text = Text1(0)
For i = 1 To 4
.SubItems(i) = Text1(i)
Next i
End With
End Sub
Private Sub Command2_Click()
’删除列表框中信息
If ListView1.ListItems.Count > 0 Then
If MsgBox("真的要删除吗?", vbQuestion + vbYesNo + vbDefaultButton2) = vbYes Then
ListView1.ListItems.Remove ListView1.SelectedItem.Index
End If
End If
End Sub
Private Sub Form_Load()
Dim tpStr As String, i As Integer
fileName = App.Path & "\data.txt"
If Dir(fileName) <> "" Then
’加载数据
Open fileName For Input As #1
Do While Not EOF(1)
With ListView1.ListItems.Add()
For i = 0 To 4
Line Input #1, tpStr
If i = 0 Then
.Text = tpStr
Else
.SubItems(i) = tpStr
End If
Next i
End With
Loop
Close #1
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim i As Integer
Dim tpList As ListItem
’保存数据
Open fileName For Output As #1
For Each tpList In ListView1.ListItems
Print #1, tpList.Text
For i = 1 To 4
Print #1, tpList.SubItems(i)
Next i
Next tpList
Close #1
End Sub
Option Explicit
Dim fileName As String
Private Sub Command1_Click()
’将文本框中的信息添加到列表框中
Dim i As Integer
With ListView1.ListItems.Add()
.Text = Text1(0)
For i = 1 To 4
.SubItems(i) = Text1(i)
Next i
End With
End Sub
Private Sub Command2_Click()
’删除列表框中信息
If ListView1.ListItems.Count > 0 Then
If MsgBox("真的要删除吗?", vbQuestion + vbYesNo + vbDefaultButton2) = vbYes Then
ListView1.ListItems.Remove ListView1.SelectedItem.Index
End If
End If
End Sub
Private Sub Form_Load()
Dim tpStr As String, i As Integer
fileName = App.Path & "\data.txt"
If Dir(fileName) <> "" Then
’加载数据
Open fileName For Input As #1
Do While Not EOF(1)
With ListView1.ListItems.Add()
For i = 0 To 4
Line Input #1, tpStr
If i = 0 Then
.Text = tpStr
Else
.SubItems(i) = tpStr
End If
Next i
End With
Loop
Close #1
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim i As Integer
Dim tpList As ListItem
’保存数据
Open fileName For Output As #1
For Each tpList In ListView1.ListItems
Print #1, tpList.Text
For i = 1 To 4
Print #1, tpList.SubItems(i)
Next i
Next tpList
Close #1
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询