If you usually have many students and friends of the information, try to prepare a computer in my address book. Very convenient yo. First of a new project, in the "toolbox -> Right -> parts," adding "Microsoft windows common control 6.0", and then add in the form of five labels, "headline" for the "name, telephone, Oicq, E - Mail, address, "add a text box (text1), and then [copy / paste 4] to a control array; add a Listview control (Listview1), in its Properties box, add five" first out " , "text" value "name, phone number, Oicq, E-Mail, address," "Show Properties" to "3 - lvwReport" selected "The whole trip choice" and "hidden options"; add two buttons , and its title attribute for the "Add", "delete." Add the following code:
Option Explicit
Dim fileName As String
Private Sub Command1_Click ()
'Text box of information will be added to the list box
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 ()
'Delete list box information
If ListView1.ListItems.Count> 0 Then
If MsgBox ( "really want to delete?" VbQuestion + + vbDefaultButton2 vbYesNo) = 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
App.Path & fileName = "\ data.txt"
If Dir (fileName) <> "" Then
'Load data
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
'Save Data
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
This procedure has been in windows98 + debugging environment through VB6.0. |