Mas betmen,
Mungkin ini bisa membantu
Asumsi :
Array yg mau diacak namanya zArray
Option Explicit
Public zArray() As Variant
Dim zArrayAwal() As Variant
Dim zArrayTarget() As Variant
Public Sub AcakArray()
Dim J_Array As Long
Dim i As Long, X As Long
If Not IsArray(zArray) Then Exit Sub
J_Array = UBound(zArray)
ReDim zArrayTarget(J_Array)
zArrayAwal = zArray
For i = 0 To J_Array
Randomize
X = UBound(zArrayAwal)
X = Int((Rnd() * (X + 1)))
Call EditArray(i, X)
Next i
zArray = zArrayTarget
Erase zArrayAwal
Erase zArrayTarget
End Sub
Public Sub EditArray(NoArrayTarget As Long, NoArrayAwal As Long)
Dim J As Long, J2_Array As Long
Dim ZArrayTmp() As Variant
If Not IsArray(zArrayAwal) Then Exit Sub
J2_Array = UBound(zArrayAwal)
If J2_Array < 0 Then Exit Sub
zArrayTarget(NoArrayTarget) = zArrayAwal(NoArrayAwal)
For J = 0 To J2_Array
If J > NoArrayAwal Then
zArrayAwal(J - 1) = zArrayAwal(J)
End If
Next J
If UBound(zArrayAwal) <= 0 Then Exit Sub
ReDim Preserve zArrayAwal(J2_Array - 1)
End Sub
-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of su_betmen nusaputra
Sent: Tuesday, September 04, 2007 9:49 PM
To: [email protected]
Subject: [Programmer-VB] Re: cara randomize array
mas ardhit_coky,
makasih atas responnya
hanya saja, dgn metode yg diusulkan terdapat mslh. yaitu hasil
pengacakannya bisa berulang. misal harusnya dari 1,2,3,4,5 menjadi
2,1,1,4,5
kmdn lagi ada masalah jika seandainya arraynya bukan urutan angka.
tapi makasih buat responnya
-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of ardhit_coky
Sent: Monday, September 03, 2007 2:16 AM
To: [email protected]
Subject: [Programmer-VB] Re: cara meng-acak array
Saya coba jawab ya, mudahan bisa.
contohnya untuk arr(5) aja ya..
Sebelumnya buat array Text1 nya 5 dulu ya....
copy paste code berikut
Private Sub Form_Load()
Dim arr(5) As Long
Dim a%
Dim b%
For i = 0 To 5
a = Rnd * 5
arr(i) = a
b = a
Text1(i).Text = b
Next i
End Sub
_____
Yahoo! oneSearch: Finally, mobile
<http://us.rd.yahoo.com/evt=48252/*http:/mobile.yahoo.com/mobileweb/ones
earch?refer=1ONXIC> search that gives answers, not web links.
_____
**
“This e-mail (including any attachments) is intended solely for the addressee
and could contain information that is confidential; If you are not the intended
recipient, you are hereby notified that any use, disclosure, copying or
dissemination of this e-mail and any attachment is strictly prohibited and you
should immediately delete it. This message does not necessarily reflect the
views of Bank Indonesia. Although this e-mail has been checked for computer
viruses, Bank Indonesia accepts no liability for any damage caused by any virus
and any malicious code transmitted by this e-mail. Therefore, the recipient
should check again for the risk of viruses, malicious codes, etc as a result of
e-mail transmission through Internet”