Click here to Skip to main content
15,063,275 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have this code

Dim time As New Random()
Dim number As Integer = Random(Label1, Label2)

However i get

'Random' is a type an cannot be used as an expression :(

any suggestions please how i can sort this please.

1 solution

IF you read the documentation youll find something like this:[^]

And the code:
Dim bytes1(99), bytes2(99) As Byte 
Dim rnd1 As New Random()
Dim rnd2 As New Random()


Console.WriteLine("First Series:")
For ctr As Integer = bytes1.GetLowerBound(0) to bytes1.GetUpperBound(0)
   Console.Write("{0, 5}", bytes1(ctr))
   If (ctr + 1) Mod 10 = 0 Then Console.WriteLine()
Console.WriteLine("Second Series:")        
For ctr As Integer = bytes2.GetLowerBound(0) to bytes2.GetUpperBound(0)
   Console.Write("{0, 5}", bytes2(ctr))
   If (ctr + 1) Mod 10 = 0 Then Console.WriteLine()

Trick is to use the Random.Next etc.
[no name] 23-May-13 12:58pm
could i use this instead?

Dim number As Integer = Random.Equals(Label1, Label 2)
Sergey Alexandrovich Kryukov 23-May-13 13:00pm
Sure, 5ed.
[no name] 23-May-13 13:05pm
ok slightly off topic but i am now trying to display the variable 'number' in a label and i have this code

label11.Text = Convert.ToString(number)

and it just doesnt do anything any suggestions please
Sergey Alexandrovich Kryukov 23-May-13 13:18pm
string someText = number.ToString(); or
string someText = number.ToString(formatString); /...
Dave Kreskowiak 23-May-13 13:27pm
You REALLY need to stop what you're doing and pickup a beginners book on VB.NET and work through it. You're missing or misunderstanding so many core concepts that it's nearly impossible for anyone to post the simplest code with the assumption that you would understand what it's doing and why.
Sergey Alexandrovich Kryukov 24-May-13 17:51pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900