I was given a task of creating a lucky draw program.

1.Total numbers of accounts are 00001 to 99999.
2.But only 131 accounts will be chosen.
3.3 sections - 1 account for 1 car, 20 accounts for 20 iPhone, 10 accounts for 10 Samsung 4.Galaxy & 100 accounts for $100 Voucher.
5.Use randomize.
6.Use sorting - ascending order.

I did manage to create the program, but I don't know how to sort the numbers according to their section.

Did I do incorrectly? Or do I need to add/edit something?

Private Sub Command1_Click()

Dim arrayno(1 To 131)
Dim luckyno
Dim counter
Dim check

For counter = 1 To 131
start:
    Randomize
    luckyno = Int((99999 * Rnd) + 1)
    For check = 1 To 131
        If luckyno = arrayno(check) Then
            GoTo start
        End If
    Next check
    
    arrayno(counter) = luckyno
    Text1(counter - 1) = arrayno(counter)
Next counter
        
End Sub

Private Sub Command2_Click()

Unload Me

End Sub

Private Sub Form_Load()

Dim i As Integer
For i = 1 To 130
Text1(i).Text = ""
Next i

End Sub

Major problems:
1) Randomize should be used when the program starts, not when you click your button.
2) Never use GOTO, it's unnecessary and in your case does nothing worthwhile.
3) In line 13, how can luckyno = arrayno(check) since arrayno(check) has no value?
4) And through whatever magic might make luckyno = arrayno(check) true, why would you want to start all over?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.