|
-
May 20th, 2013, 05:44 PM
#1
Thread Starter
Hyperactive Member
Strange error - splitting and adding to listview
hi,
friends i don't no how to fix, so here's me code:
Code:
For Each ln In IO.File.ReadAllLines(iniFile)
If ln.ToLower.StartsWith("app name") Then
Dim app_name As String = ln.Substring(ln.IndexOf(":"c) + 1) '//a faster and more efficient option than splitting
End If
App_List.Items.Add(app_name)
Next
on this line: App_List.Items.Add(app_name) it says app_name is not declared....
-
May 20th, 2013, 05:58 PM
#2
Re: Strange error - splitting and adding to listview
The problem is that you're declaring app_name inside the If .... End If statement. That means it only exist inside that code block so directly after the End If it doesn't exist anymore but there is where you're trying to add it to the App_List.Items. Even if it existed outside the If block it wouldn't have contain any value if the If statement evaluates to false. Move the App_List.Items.Add line to be inside the If block.
-
May 20th, 2013, 06:14 PM
#3
Thread Starter
Hyperactive Member
Re: Strange error - splitting and adding to listview
Yea I thought of doing that but i'm wanting to add another Else If to get the exe with the same method, then i can get a icon from the exe........
Then do App_List.Items.Add(icon, app_name)
-
May 20th, 2013, 06:31 PM
#4
Re: Strange error - splitting and adding to listview
So you thought of doing it the way it works but you thought you'd just carry on the way it doesn't? Is that supposed to make sense to anyone?
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
May 20th, 2013, 06:58 PM
#5
Thread Starter
Hyperactive Member
Re: Strange error - splitting and adding to listview
Well yea, if i move: App_list.items.add(app_name) to inside the IF, then grab the exe: ElseIf ln.ToLower.StartsWith("app file") Then
dim Exe as string = ln.Substring(ln.IndexOf(":"c) + 1) , then convert to icon.....
so how to add: icon, app_name as 1 item?
-
May 20th, 2013, 08:22 PM
#6
Re: Strange error - splitting and adding to listview
Well you don't. Not in that way. The image must be added to the ListView images list and then either the item's Image Key or Index property set to associate the image. So it's at least a two step process, assuming the image is already registered, or three if not.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
May 21st, 2013, 12:54 AM
#7
Re: Strange error - splitting and adding to listview
I don't understand what you're trying to do. What is the layout of your file? Maybe you need to read in more information from the file before you even add an item to the list?
-
May 21st, 2013, 09:13 AM
#8
Thread Starter
Hyperactive Member
Re: Strange error - splitting and adding to listview
Code:
app name:app v1
app file: blah\.......\....\.........\app.exe
this is my .ini file........
-
May 21st, 2013, 12:24 PM
#9
Re: Strange error - splitting and adding to listview
You can capture the different headers like this:-
vbnet Code:
' For Each ln In IO.File.ReadAllLines(iniFile) Dim app_name As String Dim file_name As String If ln.ToLower.StartsWith("app name") Then app_name = ln.Substring(ln.IndexOf(":"c) + 1) Continue For End If If ln.ToLower.StartsWith("app file") Then file_name = ln.Substring(ln.IndexOf(":"c) + 1) End If ''''You may add to your list here Next
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
|