I am very new to VB.NET, I want to create a Forms Application to load a text file that has lets say 50 lines, some of the lines are identical and those are grouped together and some same format but different make up. Have it loads it into a text box in the form, to see - but I want another button to randomize all the lines and then show that in the box, and then have a Save button to overwrite the orginal. Example of .txt.
line of text aa
line of text aa
line of text bb
line of text cc
line of text cc
line of text cc
line of text dd
line of text ee
line of text ee
line of text ff
line of text ff
line of text ff
Now when the list is randomized I want the identical lines to stay together, so:
line of text dd
line of text ff
line of text ff
line of text ff
line of text aa
line of text aa
line of text ee
line of text ee
line of text cc
line of text cc
line of text cc
line of text bb
So far, I have been able to Load the list into a text box on the form using openfiledialog,(which I can manually edit), clear it, and save over it. But have no idea of going about creating a button to do all the stuff I said above, here's what I have. Which I have put together by just piecing together different tutorials on youtube and a little experimenting.
Public Class Shuffle
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
Dim FileData As New System.IO.StreamReader(OpenFileDialog1.OpenFile)
ListBox.Text = FileData.ReadToEnd
FileData.Close()
End Sub
Private Sub Browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Browse.Click
OpenFileDialog1.ShowDialog()
End Sub
Private Sub Random_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Random.Click
End Sub
Private Sub Clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Clear.Click
ListBox.Clear()
End Sub
Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save.Click
Dim WriteData As New System.IO.StreamWriter(OpenFileDialog1.FileName)
WriteData.Write(ListBox.Text)
WriteData.Close()
End Sub
End Class
Any/All help is greatly appreciated.