Download Anything For Free

Scramble Kata / acak kata

akhirnya dpt jg caranya... meskipun ga ada algoritmanya sih :P
Private Sub Command1_Click()
Dim x, pos As Integer
Dim char As String
Dim s() As String

'Re-dimension the array to the size of the string in the textbox
ReDim s(Len(TextBox1.Text)) As String

'Assign each character to an element in the array
For x = 1 To Len(TextBox1.Text)
s(x) = Mid(TextBox1.Text, x, 1)

'For 1 to the size of the array, mix up the letters
For x = 1 To UBound(s)
'Pos is a random place in the array
pos = Int((Len(TextBox1.Text) - 1) * Rnd) + 1

'temporarily assign the temp character to our random letter
char = s(pos)

'Swap the characters, using the temp character to assign from the overwriten
s(pos) = s(x)
s(x) = char

'Clear the textbox and concat the value with each element in the array
TextBox1.Text = ""
For x = 1 To UBound(s)
TextBox1.Text = TextBox1.Text & s(x)
End Sub

selengkapnya di :