Vb – Visual Basic Help – 2 Pieces Of Code

====== MY PROBLEM ===================================================

I am using Visual Studio Express 2010

I have a bit of code that lists names from an array into buttons.

the names change with each event. So in one event it might have:

1. luke
2. mark
3. phil
4. mike

All of these names are individual buttons so i can click on them.

My code then removes the numbers with the following code:

Dim MyString As String = ners(i).name
Dim MyChar() As Char = {“1”, “2”, “3”, “4”, ” “, “5”, “6”, “7”, “8”, “9”, “.”, “0”}
Dim NewString As String = MyString.TrimStart(MyChar)

now the list shows as

luke
mark
phil
mike

I need help with 2 problems.

1. I need a to sort these names into alphabetical order.

2. I need to split the 1 column of buttons into 2 columns as shown below:

luke
mark
phil
mike

now becomes (please ignore the .)

luke . . . mike
mark . .. phil

====== More Examples=================================================

I want this:

Tim
John
Luke
Jason
Leena
Jill
Don

to become (please ignore the .)

Don . .. . Leena
Jill . . . .. Luke
Jason . . Tim
John

==== The Code that creates the buttons ===============================

Buttons(i) = New Button ‘Create a new button object in the array element
With Buttons(i)
.AutoEllipsis = True
.BackColor = Color.Khaki
.Left = PosLeft
.Text = NewString
.TextAlign = ContentAlignment.MiddleLeft
.Top = Tpos ‘Set top position
.Width = Bwidth ‘Set button width
.Height = Bheight
End With
Controls.Add(Buttons(i))
AddHandler Buttons(i).Click, AddressOf RunnerButton_Click
Tpos += PosBut

Leave a Reply

Your email address will not be published. Required fields are marked *