Link to home
Start Free TrialLog in
Avatar of Rowel Virgo
Rowel VirgoFlag for Philippines

asked on

How to convert C# to VB.net

This is the code, how to convert this? Thank you

private void button1_Click(object sender, EventArgs e)
{
/* Clear the list view items */
listView1.Clear();

// Stream on to the textfile
var sr = new StreamReader("data.txt");

//create an object list type of string to store your data later
List<string> l = new List<string>();

//variable to hold the data from the textfile
string data = "";

//loop through the data line by line
while ((data = sr.ReadLine()) != null)
{
// since it is comma separated split it with comma and check if it is equal to your textbox value
if (data.Split(',')[2].Trim().Equals(textBox1.Text))
{
// if found store the data to list 

//date
l.Add(data.Split(',')[0]);

//name
l.Add(data.Split(',')[1]);

//unique id
l.Add(data.Split(',')[2]);
// break the loop since you found it already no need for the loop to continue
break;
}
}
//dont forget to close the streamreader
sr.close();

//create a listview item object and pass the data to the list view
var item = new ListViewItem(l.ElementAt(0));
item.SubItems.Add(l.ElementAt(1));
item.SubItems.Add(l.ElementAt(2));
listView1.Items.Add(item);

}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rowel Virgo

ASKER

Thanks sir
Avatar of Joe Howard
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: HainKurt (https:#a42270826)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

MacroShadow
Experts-Exchange Cleanup Volunteer