Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27358

VS 2010 Confused on Random

$
0
0
I just noticed that my random numbers are NOT random. They always start at a certain number, and generate the same sequence every time my program runs anew. Here is an example of my code within the sub button_click:

Code:

Dim rando As String = CInt(Int((3 - 1 + 1) * Rnd() + 1))

                If rando = 1 Then

                    For Each ele As HtmlElement In WebWindow.WebBrowser1.Document.All
                        If ele.GetAttribute("id").ToLower = "RadioGroup0".ToLower Then
                            ele.InvokeMember("click")
                        End If
                    Next
                End If

I use a different version of this for different elements, but the results are the same. Random is not random. On other forums, they say to put your Rnd outside the loop, which in this case it is, but it's still not random! Whatever "seed" was used when I made the program is always the same seed that is used whenever the program runs and I don't know how to change that. Help?

Viewing all articles
Browse latest Browse all 27358

Trending Articles



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