Option Explicit
Dim sFileName As String
Dim iNumFile As Integer
Private Sub Form_Load()
With Label1
.BackColor = vbWhite
.BorderStyle = vbFixedSingle
.Font.Size = 11
.Caption = ""
End With
CreateFileData
SetPropListView
FillListView
End Sub
Private Sub CreateFileData()
sFileName = App.Path
If Right$(sFileName, 1) <> "" Then sFileName = sFileName & ""
sFileName = sFileName & "TempFile.txt"
iNumFile = FreeFile
If Dir$(sFileName) <> "" Then Kill sFileName
Open sFileName For Output As #iNumFile
Print #iNumFile, "5"
Print #iNumFile, "Cloud,Natali,123456,09.12.2010,"
Print #iNumFile, "Mail.ru,MyMail2,GF4545,12.10.2011,"
Print #iNumFile, "Yandex.ru,MyPost1,5588899,04.08.2015,"
Print #iNumFile, "Narod.ru,Glory,HGH77876,15.08.2015,"
Print #iNumFile, "Rambler.ru,MyPost2,876879hh,01.01.2018,"
Close #iNumFile
End Sub
Private Sub SetPropListView()
With ListView1
.View = lvwReport
.Arrange = lvwNone
.LabelEdit = lvwManual
.BorderStyle = ccNone
.Appearance = cc3D
.HideColumnHeaders = False
.HideSelection = False
.LabelWrap = True
.MultiSelect = False
.Enabled = True
.FullRowSelect = True
.GridLines = True
.Sorted = True
.Font.Size = 11
With .ColumnHeaders
.Add , , "Name", 1440, 0
.Add , , "Login", 1440, 2
.Add , , "Password", 1440, 2
.Add , , "Date", 1440, 2
.Add , , , 0.0001
End With
End With
End Sub
Private Sub FillListView()
Dim sLine As String
Dim sData As String
Dim n As Integer
Dim m As Integer
Dim i As Integer
Dim x As Integer
Dim y As Integer
iNumFile = FreeFile
Open sFileName For Input As #iNumFile
Line Input #iNumFile, sLine
n = Val(sLine)
For i = 1 To n
Line Input #iNumFile, sLine
x = InStr(1, sLine, ",")
sData = Left$(sLine, x - 1)
ListView1.ListItems.Add , , sData
m = 0
Do While m <> 3
x = InStr(x, sLine, ",")
If x > 0 Then
y = InStr(x + 1, sLine, ",")
If y > 0 Then
m = m + 1
sData = Mid$(sLine, x + 1, y - x - 1)
Select Case m
Case 2
ListView1.ListItems(i).SubItems(m) = String$(7, "*")
ListView1.ListItems(i).ListSubItems(m).Tag = sData
Case 3
ListView1.ListItems(i).SubItems(m) = sData
ListView1.ListItems(i).SubItems(m + 1) = Format(sData, "yyyymmdd")
Case Else
ListView1.ListItems(i).SubItems(m) = sData
End Select
x = x + 1
End If
End If
Debug.Print ListView1.ListItems(i).Text; " " & ListView1.ListItems(i).ListSubItems(m).Text; " " & ListView1.ListItems(i).ListSubItems(m).Tag
DoEvents
Loop
Next
Close #iNumFile
End Sub
Private Sub ListView1_Click()
Label1.Caption = "Password: " & ListView1.SelectedItem.ListSubItems(2).Tag
End Sub
Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
Dim iIndex As Integer
iIndex = ColumnHeader.Index - 1
iIndex = iIndex + 1 And iIndex = 3
ListView1.SortKey = iIndex
ListView1.SortOrder = Abs(1 - ListView1.SortOrder)
End Sub