You can tell from my question I am new at this but here goes:
Here is the Method I call:
I call it using this from my form my Form1.cs:
It works as I expected, now the call from another Method:
This is what does not work, I get this:
I don't know how to troubleshoot this.
Here is the Method I call:
private void DisplayRecord(string[,] myRecords, int currentRecord, int Records)//myRecords start at 0, ie currentRecord = 0 { textBox1.Text = " "; textBox1.Text = myRecords[currentRecord, 1].Trim(); textBox2.Text = " "; textBox2.Text = myRecords[currentRecord, 2].Trim(); textBox3.Text = " "; string DenS = " "; myRecords[0, 3] = myRecords[currentRecord, 3].Trim(); DenS = DencryptString(myRecords[0, 3]); textBox3.Text = textBox3.Text + DenS; textBox4.Text = Convert.ToString(currentRecord); textBox5.Text = Convert.ToString(Records); }
I call it using this from my form my Form1.cs:
//BRING ALL THE RECORDS INTO AN ARRAY THEN DISPLAY AS NEEDED????? string S;//??? string S1, S2, S3; var myRecords = new string[Records, 4]; // Read the file and display it line by line. THE RECORD ONLY HAS 3 LINES using (StreamReader sr = new StreamReader(path + "\\MyData.txt")) { for (int i = 0; i < Records; i = i + 1) { S = Convert.ToString(i); myRecords[i, 0] = S; S1 = sr.ReadLine(); myRecords[i, 1] = S1; S2 = sr.ReadLine(); myRecords[i, 2] = S2; S3 = sr.ReadLine(); myRecords[i, 3] = S3; } } currentRecord = 5;//FIRST RECORD IS AT 0 DisplayRecord(myRecords, currentRecord, Records);
It works as I expected, now the call from another Method:
private void button8_Click(object sender, EventArgs e) { //Go to first record currentRecord = 0;//FIRST RECORD IS AT 0 DisplayRecord(myRecords, currentRecord, Records); }
This is what does not work, I get this:
I don't know how to troubleshoot this.
Last edited by a moderator: