|
-
Jul 19th, 2007, 09:45 PM
#1
Thread Starter
New Member
[2005] listview read and save CFG
Hi,
I need to read a file .cfg (it's like an .ini) and change, read some information.
here is and exemple of the CFG file:
Code:
[rubrique]
item.0=10.0, 15, 1
item.1=12.0, 11, 5
item.2=17.0, 15, 3
etc...
First, I need to read all lines in [rubrique] and keep only the first number after = (So in the example, I want to add in my listview 10, 12 and 17
So I have a listview.
To read the CFG I use:
Code:
Declare Auto Function GetPrivateProfileString Lib "kernel32.dll" (ByVal section As String, _
ByVal key As String, ByVal defvalue As String, ByVal retval As System.Text.StringBuilder, _
ByVal bufsize As Integer, ByVal path As String) As Integer
Public Shared Function ReadCfgValue(ByVal path As String, ByVal section As String, _
ByVal key As String, Optional ByVal defvalue As String = "") As String
Dim sb As New System.Text.StringBuilder(1024)
GetPrivateProfileString(section, key, defvalue, sb, 1024, path)
Return sb.ToString()
End Function
Dim rubrique As String = ReadCfgValue("Path_of_the_CFG", "rubrique", "item.0")
Dim MyArray() As String
Dim MyString As String
MyString = (rubrique)
MyArray = Split$(MyString, ".")
ListView1.Items.Add(MyArray(0))
BUT with this code, I can add only the first number of the first item. IT's normal because I read the key item.0 but...
First question:
How can I read all items. (Important, I don't know how many item is in the CFG of the user)
If the first question is resolved, I want to be able to click on an item in my listview and change/save the number if I need (via and other Form with a textbox where the user can change the number)
Second question:
So, how can change a number in the listview and save in the .CFG
Thanks for your help...
Last edited by livai; Jul 20th, 2007 at 06:10 AM.
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
|