Posted by: Sourav | April 9, 2014

Bubble Sort in VB 6.0


Dim letra() As String

Dim cur, nxt, temp, sorted As String
Dim haba As Integer
haba = Len(Text1)
habax = haba – 1
ReDim letra(0 To habax) As String
For x = 1 To haba
letra(x – 1) = Mid(Text1, x, 1)
Next x
For a = 0 To haba – 1
For y = 0 To haba – 2
cur = Asc(letra(y))
nxt = Asc(letra(y + 1))
If cur > nxt Then
temp = letra(y + 1)
letra(y + 1) = letra(y)
letra(y) = temp
End If
Next y
Next a
For z = 0 To haba – 1
sagot = sagot & letra(z)
Next z
MsgBox (sagot)
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case Asc(“A”) To Asc(“Z”)
Case Asc(“a”) To Asc(“z”)
Case 8
Case Else
KeyAscii = 0
End Select
End Sub

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: