Mr. Nobody
Mr. Nobody

Reputation: 119

Easily generate random number in Visual Basic for Windows Phone 7

How can I get a random number (1-6) Using Visual Basic for Windows Phone? Everything I have tried already has resulted in errors. Here's an example of some code that has been producing errors:

Randomize()
Dim randnum As Integer = CInt(Int((6 * Rnd()) + 1))

"'Randomize' is not declared. Function has moved to the 'Microsoft.VisualBasic' namespace." "'Int' is not declared. It may be inaccessible due to its protection level." "'Rnd' is not declared. Function has moved to the 'Microsoft.VisualBasic' namespace."

What do I need to do? The same code works fine in Visual Basic. Thanks.

Upvotes: 0

Views: 10123

Answers (1)

igrimpe
igrimpe

Reputation: 1785

The Random Class is supported in Phone 7.x

    Dim r As New Random
    Dim From1to6 = r.Next(1, 7)

Upvotes: 2

Related Questions