I have a very basic login form, and and account form. when you login your account page with balance etc. opens up. Sound good in theory, but how do I do it in practice. I have the information in a txt file that is read during the login_click event. Please help

Thought I had a mini brainwave: create an instance of login form on the account form, then use the same variable that I used as the filename for the streamReader, to to read the information onto the form. Doesn't work?

//click event on login form
private void button1_Click(object sender, EventArgs e)
        {
            int pin;
            loginName = txtLoginUsername.Text;
            loginPin = int.Parse(txtLoginPin.Text);
            fileNames = txtLoginUsername.Text + ".txt";
            if (File.Exists(fileNames))
            {
                StreamReader sr = new StreamReader(fileNames);
                string userName = sr.ReadLine();
                pin = int.Parse(sr.ReadLine());

                if (pin == loginPin)
                {
                    MainAccountFrm nFrm = new MainAccountFrm();
                    nFrm.Show();
                }

            }
        }

// account form
private void MainAccountFrm_Load(object sender, EventArgs e)
        {
            LoginFrm Frm = new LoginFrm();
            lblUser.Text = Frm.fileNames;
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.