Clearing records in a listbox

A

Andrew Nelson

I have been trying to figure out for the last couple of hours what code is
used to clear a listbox in VBA and also how to sort the results at the end.
Attached is a copy of the code that I have written so far. Any assistance
would be greatly appreciated. Thanks!

'generate the number of random numbers needed

iRandomNumberCount = Round((stNumberofDiscrepancies * 0.1), 0)

If Val(iRandomNumberCount) >= 10 And Val(iRandomNumberCount) <= 50
Then
iTotalCount = iRandomNumberCount

ElseIf Val(iRandomNumberCount) < 10 Then
iTotalCount = 10

ElseIf Val(iRandomNumberCount) > 50 Then
iTotalCount = 50

End If

'create the header

If lstRandomNumbers.ListCount = 0 Then
lstRandomNumbers.AddItem "ID Number"

End If

'generate the numbers needed to populate in table


For iCounter = 1 To Val(iTotalCount)

'Generate random number

iRandomNumber = Int(stNumberofDiscrepancies * Rnd)

lstRandomNumbers.AddItem iRandomNumber


Next iCounter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top