Click here to Skip to main content
15,894,410 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
please solve me this error
C#
MessageBox.Show(clsVariable.+"account."+textBox1.Text);


i want
when textBox1.tex = 1 and press button1 show account1 content1 (111)
when textBox1.tex = 2 and press button1 show account1 content1 (222)
when textBox1.tex = 3 and press button1 show account1 content1 (333)

C#
namespace test
{
    public partial class clsVariable
    {
        private static string a7;
        public static string account1 { get { return a7; } set { a7 = value; } }
        private static string a8;
        public static string account2 { get { return a8; } set { a8 = value; } }
        private static string a9;
        public static string account3 { get { return a9; } set { a9 = value; } }
    }

    public partial class Form1 : Form
    {  public Form1()  {  InitializeComponent(); }
         private void Form1_Load(object sender, EventArgs e)
        {
            clsVariable.account1 = "111";
            clsVariable.account2 = "222";
            clsVariable.account3 = "333";
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show(clsVariable.+"account."+textBox1.Text);
        }
    }
}
Posted
Updated 17-Oct-12 6:24am
v7
Comments
[no name] 17-Oct-12 9:41am    
Okay so do that. What is the problem?
faezun 17-Oct-12 12:30pm    
i update my question please see it again
[no name] 17-Oct-12 9:51am    
Yes I see that. Do you mean to say that you are incapable of writing a simple "if" statement?
faezun 17-Oct-12 9:57am    
i want when textBox1.tex = 1 and press button1 must show account1 content >>>>> 111
i want when textBox1.tex = 2 and press button1 must show account2 content >>>>> 222
i want when textBox1.tex = 3 and press button1 must show account3 content >>>>> 333


i want
if textBox1.tex= 1 MessageBox.Show("account."+textBox1.Text); ==== MessageBox.Show(account1);
if textBox1.tex= 2 MessageBox.Show("account."+textBox1.Text); ==== MessageBox.Show(account2);
if textBox1.tex= 3 MessageBox.Show("account."+textBox1.Text); ==== MessageBox.Show(account3);
[no name] 17-Oct-12 9:58am    
Yes exactly. That is how you do it. What is the problem?

1 solution

 
Share this answer
 
Comments
[no name] 17-Oct-12 10:42am    
Still not sure why this is such a problem.
fjdiewornncalwe 17-Oct-12 10:51am    
The fact that it is a problem is a bigger problem than the problem itself. (WTF????) :)
faezun 17-Oct-12 12:26pm    
i update my question please see it again
fjdiewornncalwe 17-Oct-12 12:28pm    
Thank you, but nothing changes. You need to learn how to write a simple if-else statement to handle this and for that I direct your attention to the link I have provided in this answer.
faezun 17-Oct-12 12:33pm    
i don't need if - else
please see this error

MessageBox.Show(clsVariable.+"account."+textBox1.Text);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900