|
-
Mar 5th, 2003, 08:04 AM
#1
Thread Starter
Member
List Box help
Hi all
I've got a listbox that is already sorted as below.
1234 Williams Mr
1121 Henderson Mrs
0983 Harris J
0765 Thomas
I now want the list box or another to show the following.
1. Williams Mr 1234
2. Henderson Mrs 1121
3. Harris J 0983
4. Thomas 0765
Thanks
Rob
-
Mar 5th, 2003, 03:59 PM
#2
VB Code:
Dim temp() As String
Dim newlist() As String
Dim I As Integer
Dim x As Integer
ReDim newlist(ListBox1.Items.Count - 1)
For x = 0 To ListBox1.Items.Count - 1
temp = Split(ListBox1.Items.Item(x), " ")
For I = 1 To UBound(temp)
newlist(x) = newlist(x) & temp(I) & " "
Next
newlist(x) = newlist(x) & temp(0)
Next
ListBox1.Items.Clear()
For x = 0 To UBound(newlist)
ListBox1.Items.Add(newlist(x))
Next
thats quick off the top of my head...probably can be done differently(better) but it works...
Basically splits each line up...then swaps the numbers (first part) to the end...
let me know if that works for you
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Mar 5th, 2003, 04:14 PM
#3
Frenzied Member
VB Code:
Dim i As Integer, s As String
For i = 0 To Listbox1.Items.Count - 1
s = ListBox1.Items.Item(i).ToString
Listbox1.Items.Item(i) = (i + 1).ToString & "." & s.Remove(0, Len(s.Split(" ")(0))) & " " & s.Split(" ")(0)
Next
-
Mar 5th, 2003, 04:21 PM
#4
see? i knew it had to be able to be done easier..
very nice Lunatic.
(I forgot to add the 1. 2. etc... )
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
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
|