⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 通讯录系统
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form Form1 
   BackColor       =   &H80000013&
   Caption         =   "添加删除"
   ClientHeight    =   6540
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   9345
   FontTransparent =   0   'False
   LinkTopic       =   "Form1"
   Picture         =   "Form1.frx":0000
   ScaleHeight     =   6540
   ScaleWidth      =   9345
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command6 
      Caption         =   "修改"
      Height          =   615
      Left            =   4560
      Picture         =   "Form1.frx":06EA
      Style           =   1  'Graphical
      TabIndex        =   16
      Top             =   2280
      Width           =   1095
   End
   Begin VB.CommandButton Command5 
      Caption         =   "查询"
      Height          =   615
      Left            =   6600
      Picture         =   "Form1.frx":0DD4
      Style           =   1  'Graphical
      TabIndex        =   15
      Top             =   360
      Width           =   1095
   End
   Begin VB.CommandButton Command4 
      Caption         =   "退出"
      Height          =   615
      Left            =   6600
      TabIndex        =   14
      Top             =   2280
      Width           =   1095
   End
   Begin VB.CommandButton Command3 
      Caption         =   "清空"
      Height          =   615
      Left            =   4560
      Picture         =   "Form1.frx":14BE
      Style           =   1  'Graphical
      TabIndex        =   13
      Top             =   360
      Width           =   1095
   End
   Begin VB.CommandButton Command2 
      Caption         =   "删除"
      Height          =   615
      Left            =   6600
      Picture         =   "Form1.frx":1BA8
      Style           =   1  'Graphical
      TabIndex        =   12
      Top             =   1320
      Width           =   1095
   End
   Begin VB.CommandButton Command1 
      Caption         =   "添加"
      Height          =   615
      Left            =   4560
      Picture         =   "Form1.frx":1CF2
      Style           =   1  'Graphical
      TabIndex        =   11
      Top             =   1320
      Width           =   1095
   End
   Begin MSComctlLib.ListView ListView1 
      Height          =   2895
      Left            =   120
      TabIndex        =   10
      Top             =   3240
      Width           =   7695
      _ExtentX        =   13573
      _ExtentY        =   5106
      View            =   3
      LabelWrap       =   -1  'True
      HideSelection   =   0   'False
      FlatScrollBar   =   -1  'True
      FullRowSelect   =   -1  'True
      _Version        =   393217
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      NumItems        =   5
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Text            =   "姓名"
         Object.Width           =   1834
      EndProperty
      BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   1
         Text            =   "电话"
         Object.Width           =   2011
      EndProperty
      BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   2
         Text            =   "QQ"
         Object.Width           =   1869
      EndProperty
      BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   3
         Text            =   "E-mail"
         Object.Width           =   2894
      EndProperty
      BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   4
         Text            =   "地址"
         Object.Width           =   3246
      EndProperty
   End
   Begin VB.TextBox Text1 
      Height          =   270
      Index           =   4
      Left            =   960
      TabIndex        =   9
      Top             =   2400
      Width           =   1935
   End
   Begin VB.TextBox Text1 
      Height          =   270
      Index           =   3
      Left            =   960
      TabIndex        =   8
      Top             =   1920
      Width           =   1935
   End
   Begin VB.TextBox Text1 
      Height          =   270
      Index           =   2
      Left            =   960
      TabIndex        =   7
      Top             =   1440
      Width           =   1935
   End
   Begin VB.TextBox Text1 
      Height          =   270
      Index           =   1
      Left            =   960
      TabIndex        =   6
      Top             =   960
      Width           =   1935
   End
   Begin VB.TextBox Text1 
      Height          =   270
      Index           =   0
      Left            =   960
      TabIndex        =   5
      Top             =   480
      Width           =   1935
   End
   Begin VB.Label Label5 
      AutoSize        =   -1  'True
      BackColor       =   &H80000013&
      Caption         =   "地址:"
      Height          =   180
      Left            =   240
      TabIndex        =   4
      Top             =   2400
      Width           =   450
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      BackColor       =   &H80000013&
      Caption         =   "E-mail:"
      Height          =   180
      Left            =   240
      TabIndex        =   3
      Top             =   1920
      Width           =   630
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      BackColor       =   &H80000013&
      Caption         =   "QQ:"
      Height          =   180
      Left            =   240
      TabIndex        =   2
      Top             =   1440
      Width           =   270
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      BackColor       =   &H80000013&
      Caption         =   "电话:"
      Height          =   180
      Left            =   240
      TabIndex        =   1
      Top             =   1080
      Width           =   450
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackColor       =   &H80000013&
      Caption         =   "姓名:"
      Height          =   180
      Left            =   240
      TabIndex        =   0
      Top             =   480
      Width           =   450
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
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
      MsgBox "添加成功"
    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 Command3_Click()
    '清空文本框内容,以便继续填写
      Text1(0) = ""
      Text1(1) = ""
      Text1(2) = ""
      Text1(3) = ""
      Text1(4) = ""
 
 
End Sub

Private Sub Command4_Click()
Form1.Hide
End Sub

Private Sub Command5_Click()
fileName = App.Path & "\data.txt"
Dim i As Integer, strname As String
Dim name As String, tel As String, qq As String, add As String, mail As String
strname = InputBox("请输入要查询的姓名")
Open fileName For Input As #1
Do While Not EOF(1)

   Line Input #1, name
    Line Input #1, tel
     Line Input #1, qq
      Line Input #1, mail
       Line Input #1, add
  If name = strname Then
  MsgBox ("要查询的记录是" & Chr(13) & Chr(10) & "姓名" & name & Chr(13) & Chr(10) & "电话" & tel & Chr(13) & Chr(10) & "qq" & qq & Chr(13) & Chr(10) & "E-mail" & mail & Chr(13) & Chr(10) & "地址" & add)
  Exit Do
  Else
 MsgBox ("您查询的记录不存在")
 End If
 
Loop
  
  
    
Close #1
End Sub

Private Sub Command6_Click()
  ListView1.SelectedItem.Text = Text1(0)
  ListView1.SelectedItem.SubItems(1) = Text1(1)
  ListView1.SelectedItem.SubItems(2) = Text1(2)
  ListView1.SelectedItem.SubItems(3) = Text1(3)
  ListView1.SelectedItem.SubItems(4) = Text1(4)
  MsgBox ("修改成功")
End Sub

    Private Sub Form_Load()
    Dim tpStr As String, i As Integer, j As Integer
    Me.Caption = "通讯录"
    For j = 0 To 4
     Text1(j).Text = ""
    Next j
    
    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

Private Sub ListView1_Click()
 
 Text1(0) = ListView1.SelectedItem.Text
 Text1(1) = ListView1.SelectedItem.SubItems(1)
 Text1(2) = ListView1.SelectedItem.SubItems(2)
 Text1(3) = ListView1.SelectedItem.SubItems(3)
 Text1(4) = ListView1.SelectedItem.SubItems(4)
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -