I am trying to sort letters that are entered into a text box by a user. I want it to sort as the user is leaving the textbox. I thought about using the split method to create an array. The user will be entering a string of letters like "cbdafqg". I want to make sure it sorts to "abcdfgq" upon exiting. Am I on the right track or is there an easier way to do this?
VB Code:
Private Sub txtChangeCode_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtChangeCode.Leave txtChangeCode.Text = txtChangeCode.Text.ToUpper Dim strCodes(txtChangeCode.Text.Length) As String strCodes = txtChangeCode.Text.Split() Array.Sort(strCodes) Dim strSorted As String Dim i As Integer For i = 0 To strCodes.Length - 1 strSorted = strSorted & strCodes(i) Next i txtChangeCode.Text = strSorted End Sub
Am I correct that you can't split without a delimiter? like a "." or "/", etc.?
Thanks in advance.




Reply With Quote