Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8746995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:17:03+00:00 2026-06-13T12:17:03+00:00

I’ve got code and i know I’m 99% of the way there. C# coding

  • 0

I’ve got code and i know I’m 99% of the way there. C# coding in MS VS2008.

Basically I have a form that has 4 radio buttons and a Continue button. the user clicks one of the radio buttons and clicks continue, and this all works fine.

However, I want to use the value entered by the user (i.e. if they click the first button, I want a variable equal to 1, 2nd button equals 2 and so on). I tried doing this in various points but the only place I can get it to run is in the private void btnOkClick line, which means I can use the values outside this void, which is what I really want.

I’ve tried playing around with setting some enums and such (commented out in the code below), but I can’t quite get it. I know I must be close but my novice-ness is truly showing as I keep reading posts and can’t quite grasp it.

In short, I want to be able to have other classes in my VS2008 project be able to reference whatever value the user selected in the initial form.

namespace AmortClient
{
    public partial class frmLoadACTFCST : Form
    {
        public frmLoadACTFCST()
        {
            InitializeComponent();
            //set the parent of the form to the container
            //this.MdiParent = parent;
        }

        //public enum ACTFCST
        //{
        //    ACT = 1,
        //    FCST = 2,
        //    PLAN = 3,
        //    FiveYearPlan2012=4
        //}

        //private ACTFCST _actfcst = ACTFCST.ACT;
        //public ACTFCST actfcst
        //{
        //    get { return _actfcst; }
        //    set { _actfcst = value; }
        //}

        private void frmLoadACTFCST_Load(object sender, EventArgs e)
        {            

        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void btnActual_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void btnForecast_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void btnPlan_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void btn5YrPlan2012_CheckedChanged(object sender, EventArgs e)
        {

        }    

        private void btnContinue_Click(object sender, EventArgs e)
        {
            string ACTFCSTtext = "";
            int dataTypeKey = 0;

            if (btnActual.Checked)
            {
                ACTFCSTtext = btnActual.Text;
                dataTypeKey = 1;
            }
            else if (btnForecast.Checked)
            {
                ACTFCSTtext = btnForecast.Text;
                dataTypeKey = 2;
            }

            else if (btnPlan.Checked)
            {
                ACTFCSTtext = btnPlan.Text;
                dataTypeKey = 3;
            }

            else if (btn5YrPlan2012.Checked)
            {
                ACTFCSTtext = btn5YrPlan2012.Text;
                dataTypeKey = 4;
            }

            string msg = "";
            msg = ACTFCSTtext + " " + dataTypeKey;

            //btn5YrPlan2012
            MessageBox.Show(msg);
            Close();

        }

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:17:05+00:00Added an answer on June 13, 2026 at 12:17 pm

    Your dataTypeKey and ACTFCSTtext variables need to be declared as instance variables for your Form object if you want to access them from any other methods within your form. If you want to use them with some other form, you can pass them either as constructor arguments, or set some properties of said other form.

    So you’d declare them just after the class declaration if you want them to be instance variables. They should still be private, meaning they can only be accessed from within your frmLoadACTFCST class.

    public partial class frmLoadACTFCST : Form
    {
        private string ACTFCSTtext = "";
        private int dataTypeKey = 0;
    ...
    

    EDIT: if you want to access variables from one object in a different object (or static class), your options are as follows…

    1) Declare your variables as public instance variables (same as shown above but public; these are known as Properties when you give them getter and setter methods). Your class that needs access to these variables would need to have a reference to the class that owns the variables.

    Example:
    FormA has a public property named SomeString.
    FormB needs to access SomeString.
    FormB needs a reference to FormA, and would access the variable as…

    formAReference.SomeString
    

    2) Pass the values of the variables as arguments to some method for the class that needs access.

    Example:
    FormA has a private instance variable named SomeString.
    FormB needs access to SomeString.
    If FormA instantiates FormB, it can pass the value of SomeString to FormB’s constructor…

    //From within FormA's code
    FormB formB = new FormB(SomeString);
    
    //FormB's constructor
    public FormB(string someString)
    {
        this.someString = someString;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I have a small JavaScript validation script that validates inputs based on Regex. I
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have an array which has BIG numbers and small numbers in it. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.