Click here to Skip to main content
15,913,939 members
Home / Discussions / C#
   

C#

 
GeneralRe: Getting a PropertyGrid to display a value in Hex Pin
melchizedek10-Oct-07 2:18
melchizedek10-Oct-07 2:18 
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 
Hello!

I'm pretty new to C# and this is a newbie question, so I'm sure I can get help Smile | :)

I get the following message when I try to run the program in Visual C#: "The name 'rightAnswer' does not exist in the current context".

Anyway, here's the code:


<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
<br />
namespace Multiplikation<br />
{<br />
    public partial class Form1 : Form<br />
    {<br />
        public Form1()<br />
        {<br />
            InitializeComponent();<br />
        }<br />
<br />
        public void getQ()<br />
        {<br />
            Random r = new Random();<br />
            int maxRand = 9;<br />
            int firstNumber = r.Next(maxRand);<br />
            int secondNumber = r.Next(maxRand);<br />
            label3.Text = firstNumber + " * " + secondNumber;<br />
            int rightAnswer = firstNumber * secondNumber;<br />
        }<br />
<br />
        public void button1_Click(object sender, System.EventArgs e)<br />
        {<br />
            int theRight = rightAnswer;<br />
<br />
            int answer = int.Parse(textBox1.Text);<br />
<br />
            if (answer == theRight)<br />
            {<br />
                label4.Text = "Right answer!";<br />
            }<br />
<br />
            else<br />
            {<br />
                label4.Text = "Wrong Answer!";<br />
            }<br />
<br />
            getQ();<br />
        }<br />
<br />
    }<br />
}<br />

AnswerRe: How to access this variabel? Pin
Anthony Mushrow9-Oct-07 9:52
professionalAnthony Mushrow9-Oct-07 9:52 
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 

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.