Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21243

Too many If statements

$
0
0
I want to make sure that the random values I create are unique. So this is the code I use....

Code:

Do
    For x = 1 To 3
    thevalue(x) = Int((10 - 1 + 1) * Rnd + 1)
    Next x
    If thevalue(1) <> thevalue(2) Then
        If thevalue(1) <> thevalue(3) Then
            If thevalue(2) <> thevalue(3) Then
            Exit Do
            End If
        End If
    End If
Loop

The problem is that I need to create a lot of values and that means that my code will contain a huge number of If statements. So is there a more efficient way of doing this? Thanks.

Viewing all articles
Browse latest Browse all 21243

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>