mR-J Posted February 5, 2009 Posted February 5, 2009 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! Quote
Administrators PlausiblyDamp Posted February 5, 2009 Administrators Posted February 5, 2009 Something like Random r = new Random(); label1.Text = r.Next(10).ToString(); should do it (or at least be close) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mR-J Posted February 6, 2009 Author Posted February 6, 2009 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! Quote
Administrators PlausiblyDamp Posted February 6, 2009 Administrators Posted February 6, 2009 = (short) r.Next(256); Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.