Ranking numbers in VB.NET without using a range of ie Min and Max

I was wondering if anyone could point me in the right direction, please? Let's say I pull out the following table, so I would like to randomly select an identifier. I understand how to select a random number using a call to Randomize (), followed by the appropriate syntax, but I want to pre-define the range.

i.e. Table data

ID | Name

4345 Mike

3456 Lee

4567 John

There will be many names, but for this example you can use 3 or 4, etc.

Please help, I'm starting to itch: o |

+3
source share
2 answers

Just to make sure I understand what you want:

, .

, :

Dim rand As New Random()
Dim record As Integer = rand.[Next](0, myDataTable.Rows.Count)
Dim randomID As Integer = CInt(myDataTable.Rows(record)("ID"))

, , .

+2

Vb

    Dim i as integer 

   i = (Rnd * (maxval-minval)) + minval

rnd 0 1, .

0

Source: https://habr.com/ru/post/1753218/


All Articles