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

VS 2010 [RESOLVED] Random Number

$
0
0
Having trouble figuring out how to make this code work. I want a random number between 1-3, then depending on the outcome, I want it to select one of three radio buttons. This is the code I have so far minus the random number:

Code:

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

Firstly, is there an easier way to code that? Second, I'm using that code over and over. Is there a way to turn that into a function and input the name where I need it, like WEBELEMENT(RadioGroup_02)?

Third, so I'm using this code to get a random number between 1-3:

Code:

Dim rando As String = CInt(Int((3 - 1 + 1) * Rnd() + 1))
First, is there a shorter way to code that? Second, how might I combine the two codes so when rando = 1, the program does RadioGroup1, rando = 2, RadioGroup2, rando = 3, RadioGroup3? I'm sure there are so many ways to do this, but I'm having difficulty thinking of a way to make this work - just having that overwhelmed feeling and I don't know why. Sorry, that was a bit ot. Any ideas welcome.

Viewing all articles
Browse latest Browse all 27059

Trending Articles



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