Convert VB to C# CStr(Int(rnd() * 10))

mR-J

Newcomer
Joined
Feb 5, 2009
Messages
2
Hi!
I need som help. I am kind of new in programming. Could someone help me convert a VB code into C#?

The code is following

label1.Text = CStr(Int(rnd() * 10))

I've gotten as far as

label1.Text = Convert.ToString(... But how do I convert "rnd"?
This application is supose to be a one armed bandit, it's supose to pick random numbers.
Thanks for the help!
 
Thanks!
But i have new problem :confused:

I'm still trying to use the random funktion, but this time I want to ranomize the colors.

By clicking at the button different colors will appear.

VB code:
Dim shtGreen As Short
Dim shtRed As Short
Dim shtBlue As Short
shtGreen = Int(Rnd() * 256)
shtRed = Int(Rnd() * 256)
shtBlue = Int(Rnd() * 256)
Me.BackColor = Color.FromArgb(shtGreen, shtRed, shtBlue)

What is the code in C#??

Thanks!
 
Back
Top