TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Prime b
NA
810
346.8k
Help with simple program
Apr 29 2012 12:37 PM
What I'm trying do is to make program show how many times certain number has been generated. For example, if random number = 1 then +1 in the label displayed, if number 1 generated again then +1 to label which equal to 2 now and etc. Same with two and three, but in my case every time i click button , it would just display 1 in different labels and not display the sum of how many times they have been generated.... For each number i have separate label.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Random gen = new Random();
int number = gen.Next(1, 4);
label5.Text = number.ToString();
if (number == 1)
{
int sum = 0;
int count = 1;
sum += count;
label9.Text = sum.ToString();
}
else if (number == 2)
{
int sum = 0;
int count = 1;
sum += count;
label10.Text = sum.ToString();
}
else if (number == 3)
{
int sum = 0;
int count = 1;
sum += count;
label11.Text = sum.ToString();
}
}
Reply
Answers (
5
)
Visual Basic 2010 : Working with Advantech PIC 1710 as Data Acqusition System & Build Database for Battery Voltage and Current
[SOLVED]How do I make Configurable Key Down Events ???