I have a text file which consists of lines of data. Each line has units
of data seperated by semicolons, like so.
AAAA ; some text relating to AAAA ; some more text relating to AAAA
BBBB ; some text relating to BBBB ; some more text relating to BBBB
I have a form which consists of a combo box control, and text box
control.
combo box contol is called = comCrime
text box control is called = txtProtocol
I am trying to compare the value in a combo box with the contents of a
text file. I am trying to find the line in the text file that starts
with the text in the combo box. Once this line is found I would like to
populate the textbox control on my form with the text that lies between
the first and second semicolons of the line. I have tried the following
code but it isn't working. Can someone suggest a change please.
private void comCrime_TabIndexChanged(object sender, EventArgs e)
{
string[] lines = File.ReadAllLines(@"c:\protocol.txt");
foreach (string s in lines)
{
string[] items = s.Split(':');
if s.StartsWith(comCrime.Value) Then txtProtocol.Text =
s[1].ToString;
}
}