Rinaldo1961

Hi,

I trying to compare the string in a listbox and a new string:

Code Block

private void Toevogen_Click(object sender, EventArgs e)

{

string Pad = "";

int i;

Pad = folder.FullName;

if (String.IsNullOrEmpty(Pad) == true) return;if (BestandLijst.Items.Count < 0) return;for (i = 0; i <= BestandLijst.Items.Count; i++)

{

if (Pad.Equals(BestandLijst.Items.[i])) // error here

{

return;

}

BestandLijst.Items.Add(Pad);

}

}

What is the right syntax



Re: Visual C# Express Edition LisyBox qeustion

programmer01

ah, I might see your problem where you have your error:

Code Block
if (Pad.Equals(BestandLijst.Items.[i]))

try doing this instead:

Code Block

if (Pad == BestandLijst.Items.[i])

{

return;

}

make shure you use 2 = signs when using if or you will get another error

so now it should look like:

Code Block

private void Toevogen_Click(object sender, EventArgs e)

{

string Pad = "";

int i;

Pad = folder.FullName;

if (String.IsNullOrEmpty(Pad) == true) return;if (BestandLijst.Items.Count < 0) return;for (i = 0; i <= BestandLijst.Items.Count; i++)

{

if (Pad == BestandLijst.Items.[i])

{

return;

}

BestandLijst.Items.Add(Pad);

}

}

Hope this helps,

Programmer01






Re: Visual C# Express Edition LisyBox qeustion

Rinaldo1961

Yes thnx.