Hi there,
I have been having some problems with my Visual Basic. In trying to figure that out, un-installing, and reinstalling, running virus scans, etc, I have lost a lot of my time to get this assignment done. I would just keep messing around with it and try to be further along, but I must move on. I have a group project as well and do not want to let my group down. So any help would be greatly appreciated.
We have a form application with 3 tab pages. The first tab page takes input for first name, last name, phone, birth month, and birth year in textboxes. This info is to be written to a file. The next tab page has a read button that then displays the data into a list box. The next tab page has a text box to take input for a birth month and then searches through the file and lists any file that matches that birth month.
The whole thing then needs to be serialized and deserialized.
I will post what I have so far. My first question is what do I need to do to get it to read into the listbox? I have tried multiple things. None work. After the issues I had with my visual basic, I don't know if for sure it is me, (most likely), or the software.
For the display, we are supposed to use an overloaded ToString method in another class.
Do I have to use an array?
Thank you so much for any help. I will likely have more questions as I go.
private void EnterFriendBtn_Click(object sender, EventArgs e)
{
friend.FName = Console.ReadLine();
friend.LName = Console.ReadLine();
friend.Phone = Console.ReadLine();
friend.BMonth = Convert.ToInt32(Console.ReadLine());
friend.BDay = Convert.ToInt32(Console.ReadLine());
FileStream File = new FileStream("Friends.txt", FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
StreamWriter writer = new StreamWriter(File);
writer.WriteLine(ToString());
writer.Close();
File.Close();
}
private void ReadBtn_Click(object sender, EventArgs e)
{
FileStream File = new FileStream("Friends.txt", FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite);
StreamReader reader = new StreamReader(File);
string recordIn;
string[] fields;
recordIn = reader.ReadLine();
fields = recordIn.Split(',');
friend.FName = fields[0];
friend.LName = fields[1];
friend.Phone = fields[2];
friend.BMonth = Convert.ToInt32(fields[3]);
friend.BDay = Convert.ToInt32(fields[4]);
FriendList.Items.Add("{0,10}{1,10}{2,10}{3,4}{4,4}");
while (!reader.EndOfStream)
{
FriendList.Items.Add(ToString());
}
reader.Close();
File.Close();
}
private void FriendList_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void MonthEntryBtn_TextChanged(object sender, EventArgs e)
{
friend.BMonth = Convert.ToInt32(Console.ReadLine());
}
private void ReminderBtn_Click(object sender, EventArgs e)
{
}
private void MonthFriend_SelectedIndexChanged(object sender, EventArgs e)
{
}