hi guys, having abit of trouble loading up 3 collums in my listview, reading from a txt file. here is my code
Public Sub LoadServer()
Dim strServer As String
Open App.Path & "\ServerList.txt" For Input As #1
While Not EOF(1)
Input #1, strServer
sCon.sErver.ListItems.Add(, , Left$(strServer, InStr(strServer, ":") - 1), , 2).ListSubItems.Add = Split(strServer, ":")(1)
Wend
Close #1
End Sub
Dim lvwItem As ListItem
'~~~> Inside loop
'// Input the line from file and split the 3 data and store it to variables
Set lvwItem = ListView1.ListItems.Add(, , "a") '~~~> for first column
lvwItem.SubItems(1) = "ab" '~~~> for second column
lvwItem.SubItems(2) = "abc" '~~~> for third column
'~~~> End loop
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video) My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet Social Group:VBForums - Developers from India
hi guys, having abit of trouble loading up 3 collums in my listview, reading from a txt file. here is my code
Public Sub LoadServer()
Dim strServer As String
Open App.Path & "\ServerList.txt" For Input As #1
While Not EOF(1)
Input #1, strServer
sCon.sErver.ListItems.Add(, , Left$(strServer, InStr(strServer, ":") - 1), , 2).ListSubItems.Add = Split(strServer, ":")(1)
Wend
Close #1
End Sub
it places this line in seprate collums, but what my question is, how could i add stuff to a 3rd collum, lets just say my txtfile line looked like this
irc.mindspring.com:6667-username
i can manage to split the irc server and the port into seprate collums, how would i add the "username" to another collum... thanks very much guys
Try This
Code:
Private Sub Command1_Click()
Dim strServer As String
Open "c:\name.txt" For Input As #1
While Not EOF(1)
Input #1, strServer
ListView1.ListItems.Add(1).Text = Split(strServer, ":")(0)
ListView1.ListItems.Item(1).ListSubItems.Add.Text = Right(Split(strServer, "-")(0), 4)
ListView1.ListItems.Item(1).ListSubItems.Add.Text = Split(strServer, "-")(1)
Wend
Close #1
End Sub
thanks very much kind sir, works perfect.. but one last thing, i use an image list with icons for my list view, my icons wont show using this code.. how can i add my icon back to the list view.. the icon index is "1"... thanks
there isnt always 4 digits, so how could i make it read it diffrent? thanks
Code:
Dim strTemp As String
Dim strSite As String, strPort As String, strUser As String
strTemp = "irc.mindspring.com:6667-username" '~~~> for testing
strSite = Mid(strTemp, 1, InStr(strTemp, ":") - 1)
strPort = Mid(strTemp, InStr(strTemp, ":") + 1, InStr(strTemp, "-") - Len(strSite) - 2)
strUser = Mid(strTemp, InStr(strTemp, "-") + 1)
MsgBox strSite
MsgBox strPort
MsgBox strUser
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video) My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet Social Group:VBForums - Developers from India
Private Sub Command1_Click()
Dim lvwItem As ListItem
Dim strServer As String
Open "c:\name.txt" For Input As #1
While Not EOF(1)
Input #1, strServer
Set lvwItem = ListView1.ListItems.Add(, , Split(strServer, ":")(0),,2) '~~> with icon index 2
lvwItem.SubItems(1) =Split((Split(strServer, "-")(0)), ":")(1)
lvwItem.SubItems(2) =Split(strServer, "-")(1)
Wend
Close #1
End Sub
(not tested)
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video) My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet Social Group:VBForums - Developers from India
Does that solved your issue...???? If so, please Mark the Thread as RESOLVED (you can find the link in Thread Tools, situated at the top of this page)
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video) My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet Social Group:VBForums - Developers from India