Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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!

Posted

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!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...