|
-
Jan 7th, 2007, 06:50 PM
#1
Thread Starter
New Member
HELP!!! with Bubblesort
I'm a rookie coder, here is the code I've created, but would like to know how to adda bubble sort to the already existing code.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim arrMyArray As New ArrayList
Dim arrLtr As New ArrayList
Dim arrCount As New ArrayList
Dim icounter, x, icount As Integer
Dim strName As String = TextBox1.Text.ToLower
Dim arrNBR As New ArrayList
For icounter = 1 To TextBox1.Text.Length
arrMyArray.Add(Mid(strName, icounter, 1))
Next icounter
arrMyArray.Sort()
For icounter = 0 To arrMyArray.Count - 1
If icounter < arrMyArray.Count - 1 Then
x = StrComp(arrMyArray(icounter), arrMyArray(icounter + 1), CompareMethod.Text)
If x = 0 Then
icount += 1
Else
icount += 1
arrLtr.Add(arrMyArray(icounter))
arrNBR.Add(icount)
icount = 0
End If
Else
x = StrComp(arrMyArray(icounter), arrMyArray(icounter - 1), CompareMethod.Text)
If x = 0 Then
icount += 1
arrLtr.Add(arrMyArray(icounter))
arrNBR.Add(icount)
Else
icount += 1
arrLtr.Add(arrMyArray(icounter))
arrNBR.Add(icount)
End If
End If
Next
For x = 0 To arrLtr.Count - 1
Label1.Text = Label1.Text + arrLtr(x) + " = " + CStr(arrNBR(x)) & vbCrLf
Next
End Sub
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
|