-
I have a listview with 5 columns. I'm trying to split a string where there are spaces. Right now the data is all in column one, whereas, it should be split in all five columns. How can I split the string "sztemp" in the followin code so that it's in five columns? Thanks!
Dim xItem As ListItem
Set xItem = Form1.ListView1.ListItems.Add(Form1.ListView1.ListItems.COUNT + 1, , sztemp)
-
Assuming that the sztemp contains 5 strings that are seperated by space.(e.g sztemp = "Hello Hutty, How are you?")
This'll add 5 row items to column 1
==========================================
Dim xItem As ListItem
Dim i as integer
Dim ItemArr() as String
ItemArr = Split(sztemp)
For i = 0 to Ubound(ItemArr)
Set xItem = Form1.ListView1.ListItems.Add(Form1.ListView1.ListItems.COUNT + 1, , ItemArr(i))
Next
============================================
Or this'll add 5 column items to row 1
==========================================
Dim xItem As ListItem
Dim i as integer
Dim ItemArr() as String
ItemArr = Split(sztemp)
Set xItem = Form1.ListView1.ListItems.Add(Form1.ListView1.ListItems.COUNT + 1, , ItemArr(0))
For i = 1 to Ubound(ItemArr)
xItem.ListSubItems.Add xItem.ListSubItems.Count + 1, , ItemArr(i)
Next
============================================
Joon
-
Joon,
The second one worked! Is it possible to add lines to the right or left in columns? Same as a grid. Thanks again!
-
If you used Split function and it worked, the you have VB6....If you have VB6 then all you have to do is right click the ListView and select properties. Make sure Grid Lines check box is checked. THAT'S IT.
------------------
Serge
Senior Programmer Analyst
[email protected]
[email protected]
ICQ#: 51055819
-
That was too easy Serge. Thanks!