Type expected

Franglais

Member
Joined
Aug 26, 2004
Messages
6
Location
South of France
Programming Experience
Beginner
Type expected [RESOLVED]

I am trying to use the random class in a program but receive the following:

Dim randomObject As Random = New Random

The Random is underlined and a message saying "type expected". I have Imports.System and have tried Imports.Random but have not been able to resolve the problem. Funny though, when doing the same thing in a Console application I do not encounter the same error, it works.

Any ideas anybody, I have spent ages trying to work it out. I am new to programming though so I could well be missing the obvious.
 
Last edited:
I have noticed that if I put

Dim randomObject as System.Random = New System.Random

The error does not occur and the program works. Can anyone explain to me why even though I have included "Imports System"?
 
Dim RandomNumber As New Random
Dim intSelectedNumber As Integer = RandomNumber.Next(1, 10)


with 1 being the lowest number it'll be able to pick, and 10 being the highest number it'll be able to pick
 
Back
Top