I have struggled to find a way to make this work. I have a listbox that has 5 items. These items are lets say Company Name, Address, User Name, Phone, Fax. On the form I also have the same labels with richtextboxes under each of the above names.
What I am looking to do is have each listbox item equal the text that is related to each textbox. Then write to file from the listbox.The file created should be the text from the related textboxes.
The goal is to allow the user to re-arrange the items in the listbox via drag and drop (which I think I have figured out) and write a new order of the file.
Here is my code Code:
Private Sub listBoxCompInfo_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listBoxCompInfo.SelectedIndexChanged listBoxCompInfo.SelectedItem(0) = rtbCompName.Text listBoxCompInfo.SelectedItem(1) = rtbCompAddr1.Text listBoxCompInfo.SelectedItem(1) = rtbCompAddr2.Text listBoxCompInfo.SelectedItem(2) = rtbProgrammer.Text listBoxCompInfo.SelectedItem(3) = rtbPartNumer.Text listBoxCompInfo.SelectedItem(4) = rtbMachineName.Text listBoxCompInfo.SelectedItem(5) = rtbComments.Text Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveSettngs.Click Dim ItemArray(Me.listBoxCompInfo.Items.Count - 1) As Object Me.listBoxCompInfo.Items.CopyTo(ItemArray, 0) Dim Data As String = Join(ItemArray, Environment.NewLine) My.Computer.FileSystem.WriteAllText("c:\test.txt", Data, False) End Sub
Any Help would be greatly appreciated!




Reply With Quote