473,503 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dialogresult scope problem

Ant
Hi,
I'm new to C# & just experimenting with how to use it. I can't figure out
why I can't do this.
The dialog result object is not 'seen' in the while statement of the do
loop, yet the integer is. why is this so?

The

do
{
// declare the int
int iCount = 0;
iCount++;

// declare the dialog result object
DialogResult drDoAgain;

drDoAgain = MessageBox.Show(strOP,"Do again?", MessageBoxButtons.YesNo);
}
while ( iCount < 10 && drDoagain == DialogResult.Yes);
Thanks for any help.
Ant

Nov 17 '05 #1
3 1354
Ant,

I'm compiling on .NET 2.0 beta 2, and I get an error for both variables
being out of scope, iCount and drDoagain.

Why not just declare them outside your loop?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ant" <An*@discussions.microsoft.com> wrote in message
news:14**********************************@microsof t.com...
Hi,
I'm new to C# & just experimenting with how to use it. I can't figure out
why I can't do this.
The dialog result object is not 'seen' in the while statement of the do
loop, yet the integer is. why is this so?

The

do
{
// declare the int
int iCount = 0;
iCount++;

// declare the dialog result object
DialogResult drDoAgain;

drDoAgain = MessageBox.Show(strOP,"Do again?", MessageBoxButtons.YesNo);
}
while ( iCount < 10 && drDoagain == DialogResult.Yes);
Thanks for any help.
Ant

Nov 17 '05 #2
Hi Ant,

The integer should not be available either, so if you don't get a compiler error you probably have a global duplicate declared somewhere.

do/while is the same as while/(do) except the body is always executed once. The scope is the same.
On Fri, 08 Jul 2005 16:44:04 +0200, Ant <An*@discussions.microsoft.com> wrote:
Hi,
I'm new to C# & just experimenting with how to use it. I can't figure out
why I can't do this.
The dialog result object is not 'seen' in the while statement of the do
loop, yet the integer is. why is this so?

The

do
{
// declare the int
int iCount = 0;
iCount++;

// declare the dialog result object
DialogResult drDoAgain;

drDoAgain = MessageBox.Show(strOP,"Do again?", MessageBoxButtons.YesNo);
}
while ( iCount < 10 && drDoagain == DialogResult.Yes);
Thanks for any help.
Ant


--
Happy coding!
Morten Wennevik [C# MVP]
Nov 17 '05 #3
Ant
Hi,
Thanks for your response,

I tried your idea of declaring them out of scope (before the loop) but now I
get an "Use of unsigned variable" error when I compile. I assign drResult ==
MessageBox.Show (); so it does have a return value. Hmmm. Any other ideas?

Many thanks
Ant

"Nicholas Paldino [.NET/C# MVP]" wrote:
Ant,

I'm compiling on .NET 2.0 beta 2, and I get an error for both variables
being out of scope, iCount and drDoagain.

Why not just declare them outside your loop?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ant" <An*@discussions.microsoft.com> wrote in message
news:14**********************************@microsof t.com...
Hi,
I'm new to C# & just experimenting with how to use it. I can't figure out
why I can't do this.
The dialog result object is not 'seen' in the while statement of the do
loop, yet the integer is. why is this so?

The

do
{
// declare the int
int iCount = 0;
iCount++;

// declare the dialog result object
DialogResult drDoAgain;

drDoAgain = MessageBox.Show(strOP,"Do again?", MessageBoxButtons.YesNo);
}
while ( iCount < 10 && drDoagain == DialogResult.Yes);
Thanks for any help.
Ant


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3352
by: Roman Muntyanu | last post by:
Hi all I have modal dialog that has DialogResult=Ok button I need to check some data in dialog when I click Ok before returning to calling form. Any tips would be appreciated Thanks, Roman
5
3683
by: Daniel | last post by:
what do you have to do in a C# dialog so that it returns to ShowDialog as DialogResult.OK ?
2
17716
by: steve bull | last post by:
I have built what I think should be a dialog box. It contains 4 tabbed panes for generating a range of colors. Each tabbed pane consists of a panel with all the widgets on them including the OK and...
7
2631
by: Frank Maxey | last post by:
I am fairly new to VB.Net and am having a curious problem. I have an entry dialog form called from a main form. The calling form needs to check the DialogResult field for an OK response. In...
2
7532
by: dm1608 | last post by:
I'm opening my own form and doing something like: If dlgDirectory.ShowDialog() = DialogResult.OK Then .... End If When I compile the project, I can a warning for the line saying: Access of...
11
2630
by: rk | last post by:
According to the docs, I would expect to check the result of an OpenFileDialog in a VS 2005 CLR Windows Forms application this way: if (openFileDialog1->ShowDialog()== DialogResult::OK) ...
1
2345
by: Bill Cart | last post by:
I am trying to work with 2 forms. If I set the ModalResult of a button on the 2nd form it works OK. If I try to assign the result and then return it does not return the value I set. 1st Form...
7
5574
by: Masterfrier | last post by:
Hi there! in my app, i open a Dialog, in this dialog i use the FileOpenDialog, when i click on 'Ok' or 'Cancel' in my FileOpenDialog, it automatically closes the parent dialog, with a...
2
6960
by: WP | last post by:
Hello, I making and Windows Forms program and I have a dialog with two buttons. I have set the DialogResult property for these buttons to DialogResult.OK and DialogResult.No, respectively (however,...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5592
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5021
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4685
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1519
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
397
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.