|
-
Feb 3rd, 2008, 02:00 AM
#1
Thread Starter
Interweb adm/o/distrator
Last edited by Paul M; Feb 3rd, 2008 at 02:04 AM.
-
Feb 3rd, 2008, 06:02 AM
#2
Thread Starter
Interweb adm/o/distrator
Re: Listview Saving/loading
Here is what i have so far the Saving seems to be alright, now just need to load 
Code:
Public Function SaveSites(ByVal Listv As ListView)
filenum = FreeFile
If Listv.ListItems.Count > 0 Then
Open App.Path & "\Sites.txt" For Input As #filenum
strbuffer = Input(filesize, #filenum)
Close #filenum
Open App.Path & "\Sites.txt" For Append As #filenum
For i = 1 To Listv.ListItems.Count
Print #filenum, Listv.ListItems(i) + ";" + Listv.ListItems(i).SubItems(i)
Next i
Close #filenum
End If
End Function
Code:
Public Function LoadSites(ByVal Listv As ListView)
'this is totally messed!
'please forgive me for this function
'i am just trying things
Dim str1a() As String
Dim str1b() As String
filenum = FreeFile
Open App.Path & "\Sites.txt" For Input As #filenum
str1a() = Split(Input(LOF(1), 1), vbCrLf)
Close #filenum
str1b() = Split(str1a, ";")
For i = 0 To UBound(str1b) - 1
Listv.ListItems.Add , , str1b(i)
Next i
End Function
-
Feb 3rd, 2008, 03:02 PM
#3
Re: Listview Saving/loading
Try this:
Code:
Public Sub SaveSites(LV As ListView, FilePath As String)
Dim l As Long, intFF As Integer
intFF = FreeFile
With LV
If .ListItems.Count > 0 Then
'Remove this line to not delete file before saving.
SafeKill FilePath
Open FilePath For Append As #intFF
For l = 1 To .ListItems.Count
Print #intFF, .ListItems(l).Text & ";" & .ListItems(l).SubItems(1)
Next l
Close #intFF
End If
End With
End Sub
Public Sub LoadSites(LV As ListView, FilePath As String)
Dim strLine As String, strInfo() As String
Dim intFF As Integer
intFF = FreeFile
With LV
.ListItems.Clear
Open FilePath For Input As #intFF
If LOF(intFF) > 0 Then
Do While Not EOF(intFF)
Line Input #intFF, strLine
If InStr(1, strLine, ";") > 0 Then
strInfo = Split(strLine, ";")
.ListItems.Add , , strInfo(0)
.ListItems(.ListItems.Count).SubItems(1) = strInfo(1)
End If
Loop
End If
Close #intFF
End With
Erase strInfo
End Sub
Public Sub SafeKill(FilePath As String)
On Error Resume Next
Kill FilePath
End Sub
Then you use it like:
vb Code:
'Load sites into ListView1: LoadSites ListView1, App.Path & "\sites.txt" 'Save sites from ListView1: SaveSites ListView1, App.Path & "\sites.txt"
Edit:
The best way to check if the URL is already there is to check before adding to the ListView.
Last edited by DigiRev; Feb 3rd, 2008 at 03:06 PM.
-
Feb 3rd, 2008, 04:51 PM
#4
Thread Starter
Interweb adm/o/distrator
Re: Listview Saving/loading
Yea thanks i woke up for some reason in the middle of the night and got it working
Thanks though
-
Feb 3rd, 2008, 07:14 PM
#5
Thread Starter
Interweb adm/o/distrator
Re: [RESOLVED] Listview Saving/loading
o.O
This in my save function is getting Invalid Property Value?
Code:
For i = 1 To .ListItems.Count
Print #filenum, .ListItems(i).Text & ";" & .ListItems(i).SubItems(i)
Next i
-
Feb 3rd, 2008, 09:16 PM
#6
Thread Starter
Interweb adm/o/distrator
Re: Listview Saving/loading
Hmmm the funny thing is this was working a while ago, also i just checked MSDN and done a search can't seem to find anything
-
Feb 4th, 2008, 03:10 AM
#7
Thread Starter
Interweb adm/o/distrator
Re: Listview Saving/loading
Sorry maybe the full code from the routine will help...
Code:
filenum = FreeFile
With ListV
If .ListItems.Count > 0 Then
Open filepath For Append As #filenum
For i = 1 To .ListItems.Count
Print #filenum, .ListItems(i).Text & ";" & .ListItems(i).SubItems(1)
Next i
Close #filenum
End If
End With
Nevermind answer ^
Last edited by Paul M; Feb 4th, 2008 at 03:15 AM.
-
Feb 4th, 2008, 03:15 AM
#8
Thread Starter
Interweb adm/o/distrator
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|