Click here to Skip to main content
15,902,842 members
Home / Discussions / C#
   

C#

 
AnswerRe: Cool Idea Of The Day Pin
eggsovereasy9-Oct-07 10:24
eggsovereasy9-Oct-07 10:24 
GeneralRe: Cool Idea Of The Day Pin
Malcolm Smart9-Oct-07 10:25
Malcolm Smart9-Oct-07 10:25 
GeneralRe: Cool Idea Of The Day Pin
eggsovereasy9-Oct-07 11:06
eggsovereasy9-Oct-07 11:06 
QuestionGet Domain Names on specific IP Address Pin
Davids Maguire9-Oct-07 10:00
Davids Maguire9-Oct-07 10:00 
AnswerRe: Get Domain Names on specific IP Address Pin
Peter Vertes9-Oct-07 10:02
Peter Vertes9-Oct-07 10:02 
AnswerRe: Get Domain Names on specific IP Address Pin
mr_lasseter9-Oct-07 15:36
mr_lasseter9-Oct-07 15:36 
QuestionHow to access this variabel? Pin
Joplinazz9-Oct-07 9:48
Joplinazz9-Oct-07 9:48 
AnswerRe: How to access this variabel? Pin
Anthony Mushrow9-Oct-07 9:52
professionalAnthony Mushrow9-Oct-07 9:52 
The variable 'rightAnswer' is only local to the method getQ()
And you can't access it from anywhere else.

Add a class variable or something, so you'd end up with:

public partial class Form1 : Form
{
private int rightAnswer;

...

public void getQ()
{
Random r = new Random();
int maxRand = 9;
int firstNumber = r.Next(maxRand);
int secondNumber = r.Next(maxRand);
label3.Text = firstNumber + " * " + secondNumber;
rightAnswer = firstNumber * secondNumber;
}

public void button1_Click(object sender, System.EventArgs e)
{
int answer = int.Parse(textBox1.Text);

if (answer == rightAnswer)
{
label4.Text = "Right answer!";
}

...

My current favourite word is: Waffle

Cheese is still good though.

AnswerRe: How to access this variabel? Pin
Scott Dorman9-Oct-07 9:59
professionalScott Dorman9-Oct-07 9:59 
QuestionInstallation System Pin
Ken Mazaika9-Oct-07 9:30
Ken Mazaika9-Oct-07 9:30 
AnswerRe: Installation System Pin
il_masacratore9-Oct-07 21:36
il_masacratore9-Oct-07 21:36 
Question...(object sender, System.EventArgs e) Pin
Imran Adam9-Oct-07 8:43
Imran Adam9-Oct-07 8:43 
AnswerRe: ...(object sender, System.EventArgs e) Pin
Not Active9-Oct-07 8:59
mentorNot Active9-Oct-07 8:59 
GeneralRe: ...(object sender, System.EventArgs e) Pin
Imran Adam9-Oct-07 9:04
Imran Adam9-Oct-07 9:04 
AnswerRe: ...(object sender, System.EventArgs e) Pin
Scott Dorman9-Oct-07 9:49
professionalScott Dorman9-Oct-07 9:49 
GeneralRe: ...(object sender, System.EventArgs e) Pin
Imran Adam9-Oct-07 10:17
Imran Adam9-Oct-07 10:17 
GeneralRe: ...(object sender, System.EventArgs e) Pin
Scott Dorman9-Oct-07 10:27
professionalScott Dorman9-Oct-07 10:27 
QuestionDataGridView HeaderCell Painting Pin
cris34569-Oct-07 7:30
cris34569-Oct-07 7:30 
Questionsocket server disconnect Pin
gizmokaka9-Oct-07 7:25
gizmokaka9-Oct-07 7:25 
AnswerRe: socket server disconnect Pin
led mike9-Oct-07 7:54
led mike9-Oct-07 7:54 
GeneralRe: socket server disconnect Pin
gizmokaka9-Oct-07 8:09
gizmokaka9-Oct-07 8:09 
GeneralRe: socket server disconnect Pin
led mike9-Oct-07 8:29
led mike9-Oct-07 8:29 
Questionlabel text distorted in windows form Pin
sudhirkamath9-Oct-07 6:28
sudhirkamath9-Oct-07 6:28 
AnswerRe: label text distorted in windows form Pin
Juraj Borza9-Oct-07 9:44
Juraj Borza9-Oct-07 9:44 
GeneralRe: label text distorted in windows form Pin
Peter Vertes9-Oct-07 10:06
Peter Vertes9-Oct-07 10:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.