how can i make a random number not to always appear every time i open the program
my code always prints or present same number every time i open and terminate and open it again and again it always shows same number but if i click a button for random it does show random number
this code just my example:
note: this is just an example not my true code in my program...

Dim rndm As Integer
    Randomize
    rndm = Int(4 * Rnd())
    Select Case rndm
    Case 1
        list1.additem = 1
    Case 2
        list1.additem= 2
    Case 3
        list1.additem = 3
    Case 4
        list1.additem = 4
    End Select

Recommended Answers

All 2 Replies

why you need a case for populating the list.

Why not use a simple FOR loop for the purpose.

Your problem is that the random number is not saved to your system, hence the same number every time it starts. Save the random number to your registry and let the app select a random number from this number. Google "Save number to registry in VB6", plenty of samples to choose from.

You can also save this number to a database, call it from there and then call for a random number.

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.