|
-
Feb 2nd, 2000, 02:55 AM
#1
Thread Starter
Addicted Member
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)
-
Feb 2nd, 2000, 04:14 AM
#2
Member
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
-
Feb 2nd, 2000, 04:45 AM
#3
Thread Starter
Addicted Member
Joon,
The second one worked! Is it possible to add lines to the right or left in columns? Same as a grid. Thanks again!
-
Feb 2nd, 2000, 05:10 AM
#4
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
-
Feb 2nd, 2000, 05:15 AM
#5
Thread Starter
Addicted Member
That was too easy Serge. Thanks!
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
|