|
-
Jan 27th, 2008, 11:49 AM
#1
Thread Starter
Junior Member
[RESOLVED] New to C#: Calling Functions
I have a piece of code that I need to call a function to save settings. This is what I'm using currently.:
Code:
private void exeSaveBut_Click(object sender, EventArgs e)
{
MainForm exeSave = new MainForm();
exeSave.exeSaveAction();
}
...
void exeSaveAction()
{
MessageBox.Show("VPSM Directory Settings Have Been Saved!", "Settings Saved");
exe42PathBox.Text = Convert.ToString(Settings1.Default.ExePath42);
exe50PathBox.Text = Convert.ToString(Settings1.Default.ExePath50);
exe52PathBox.Text = Convert.ToString(Settings1.Default.ExePath52);
exe60PathBox.Text = Convert.ToString(Settings1.Default.ExePath60);
exe62PathBox.Text = Convert.ToString(Settings1.Default.ExePath62);
exe70PathBox.Text = Convert.ToString(Settings1.Default.ExePath70);
exe71PathBox.Text = Convert.ToString(Settings1.Default.ExePath71);
Settings1.Default.Save();
}
Now when I click on the button it doesn't seem to call the function...what am I doing wrong, I know it's a stupid, easy answer but I can't seem to find information that actually works for me. Thanks.
-
Jan 27th, 2008, 12:43 PM
#2
Re: New to C#: Calling Functions
Does that code even compile? The default access modifier of a class member is private, so you shouldnt be able to access the exeSaveAction method from that class, you need to add the 'public' modifier infront of 'void'
-
Jan 27th, 2008, 02:20 PM
#3
Thread Starter
Junior Member
Re: New to C#: Calling Functions
Yeah it compiles without errors or warnings. Even with public in front the button still does not ultimately display the message box, or seem to do anything and I can't figure out why.
-
Jan 27th, 2008, 02:27 PM
#4
Re: New to C#: Calling Functions
What if you put a breakpoint in the buttons click event handler, and step through the code? What actually happens? Does it even enter the event handler?
-
Jan 28th, 2008, 12:38 AM
#5
Thread Starter
Junior Member
Re: New to C#: Calling Functions
It wasn't stepping into it, had to re-"double-click" the buttons. My guess is a reference in the designer file was a little confused when I went from a form based program to a tab based one. Thanks for the help. Should have tried that myself first though ;-)
-
Feb 4th, 2008, 04:07 AM
#6
Re: New to C#: Calling Functions
 Originally Posted by Atheist
The default access modifier of a class member is private
Bzzt. Public.
You may be thinking of Java.
-
Feb 4th, 2008, 04:51 AM
#7
Re: New to C#: Calling Functions
 Originally Posted by penagate
Bzzt. Public.
You may be thinking of Java.
http://msdn2.microsoft.com/en-us/lib...w2(VS.80).aspx
You may be thinking of VB.
Last edited by jmcilhinney; Feb 4th, 2008 at 05:08 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|