I need your help with my sample project to read the ini string for listview but I couldn't find a sample one. If I had one for myself then I wouldn't have posting my request on the forum, I would have build one for myself. I need your help with this. It have to be reading one line in each sentence only.
You still have the rights to open my sample string to rewrite and send it back.
Thanks,
Mark
Last edited by Mark103; Nov 1st, 2007 at 05:17 PM.
Don't remember where I came across these functions, but here they are:
vb Code:
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Function GetFromINI(sSection As String, sKey As String, sDefault As String, sIniFile As String)
Ok, I have sort that out but I made a mistake and choose the wrong box which string I would like to read. Really I should have chose listbox even not listview.
Code:
Private Sub Form_Load()
Dim FNum, a$, s$()
FNum = FreeFile
List1.ListItems.Clear
Open App.Path + "\test.ini" For Input As #FNum
Do
Line Input #FNum, a$
Loop Until EOF(FNum) Or a$ = ""
While Not EOF(FNum)
Line Input #1, a$
If a$ <> "" Then
If InStr(a$, "=") Then 'if there's an "="
s = Split(a$, "=")
List1.ListItems.Add , , s$(1)
End If
End If
Wend
Close #FNum
FreeFile FNum
Close #FNum
End Sub
It won't read the string for my listbox as I have received the following error "compile error: Method or data member not found". I have no idea how to solve this problem. Is there any other way to get my problem resolving??
Thanks,
Mark
Last edited by Mark103; Oct 24th, 2007 at 07:05 PM.
If List1 is a listbox then it won't have a ListItems collection, which is found in a listview control. List1.AddItem is the method for adding items to a listbox.
If List1 is a listbox then it won't have a ListItems collection, which is found in a listview control. List1.AddItem is the method for adding items to a listbox.
Thanks, I tried to exchange the code but still received the same error. I am still trying to use listbox. What is the correct code??
Sorry about that but I picked out the lesson I was meant to learn.
Thanks,
Mark
Last edited by Mark103; Oct 24th, 2007 at 08:33 PM.