Load Text File - Randomize Lines - Save/Replace



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.
If your loading the items into array list then sort the array to group the items.
hi andy,  

  

could you please explain in more details what exactly you need to achieve, because i am still not sure i understand you correctly?  

  

please note that when you are using the code below, you are overriding the text of the selected item - in your case this is the first item in the radcombombobox(with the empty text):  


`ddlfuturecode.selecteditem.text =` `"futurecode"`

  

if you want to select an item from the radcombobox by its text, you can use the following code instead:  


`ddlfuturecode.finditembytext(``"futurecode"``).selected =` `true`

  

so the changed vb code should look like the following:  


`dim` `ddlfuturecode` `as` `new` `radcombobox`
 
`with` `ddlfuturecode`
`.items.clear()`
`.items.add(``new` `radcomboboxitem(``""``, 0))`
`.items.add(``new` `radcomboboxitem(``"1"``, 1))`
`.items.add(``new` `radcomboboxitem(``"futurecode"``, 2))`
`.databind()`
`end` `with`
 
`ddlfuturecode.finditembytext(``"futurecode"``).selected =` `true`
 
`form1.controls.add(ddlfuturecode)`

  

  

regards,  

 aneliya petkova   

telerik

do you want to have your say when we set our development plans?
do you want to know when a feature you care about is added or when a bug fixed?
explore the [telerik feedback portal](http://www.telerik.com/support/feedback)
and vote to affect the priority of the items How you do this will depend on a number of factors: since you haven't tried to explain in any detail, I'll assume you know nothing, and just give you the basics.  

  

The easiest way to do this is to read the text file into a single string, and then use the .NET framework to find the match:  


```
Dim text As String = File.ReadAllText("D:\Temp\MyFile.txt")
Dim index As Integer = text.IndexOf("hello")
If index >= 0 Then
   ' String is in file, starting at character "index"
End If
```
  

There are other ways, but that is pretty much the simplest. Dapper just wraps raw ADO.NET; raw ADO.NET doesn't offer a facility for this, therefore dapper does not. What you want is `SqlBulkCopy`. You could *also* use a table-valued-parameter, but this really feels like a `SqlBulkCopy` job.


In a pinch, you can *use* dapper here - `Execute` will unroll an `IEnumerable<T>` into a series of commands about `T` - but it will be lots of commands; and unless you explicitly enable async-pipelining, it will suffer from latency per-command (the pipelined mode avoids this, but it will still be n commands). But `SqlBulkCopy` will be *much* more efficient.


If the input data is an `IEnumerable<T>`, you might want to use `ObjectReader` from FastMember; for example:



```
IEnumerable<SomeType> data = ...
using(var bcp = new SqlBulkCopy(connection))
using(var reader = ObjectReader.Create(data, "Id", "Name", "Description"))
{
    bcp.DestinationTableName = "SomeTable";
    bcp.WriteToServer(reader);
}

``` see [creating feedback loops](https://vvvv.org/documentation/creating-feedback-loops).

it’s only the subtype of a datatype. don’t worry about that.

fyi: create an [asstring (value)](https://vvvv.org/documentation/asstring-(value)) and check its sub type for possible subtypes of the datatype “value” [image] nirgrahamuk:

observe({

fv <- req(input$filter\_var)

td <- req(tabledata())

updateselectizeinput(inputid = "filter\_vals",

choices = pull(td,fv))

})

observe({

fv <- as.character(req(input$filter\_var))

td <- req(table… You can use the XPATH syntax:



```
var span = doc.DocumentNode.SelectSingleNode("//span[@class='dropDownButton ownCity coords']");
var anchorText = span.ChildNodes["a"].InnerText;

```

You can also use LINQ:



```
var anchorTexts = 
    from span in doc.DocumentNode.Descendants("span")
    where span.GetAttributeValue("class", "") == "dropDownButton ownCity coords" 
    from anchor in span.Descendants("a") 
    select anchor.InnerText;
string anchorText = anchorTexts.FirstOrDefault();

``` we’re glad to announce that this feature is now available in production on [bitrise.io](http://bitrise.io) :tada:

related [#changelog](/c/6-changelog) / [#announcements](http://discuss.bitrise.io/tags/announcements) :

[image]

[secret env vars and (generic) file storage files: control whether it’s available in pull request builds](http://discuss.bitrise.io/t/secret-env-vars-and-generic-file-storage-files-control-whether-it-s-available-in-pull-request-builds/2790) [changelog](/c/changelog)

related [#feature-r…](/c/9-feature-request) hey [@andre601](/u/andre601) ! i think there is a webhook that fires for that:

<https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request>

check out the action key in the payload, it has support for state changes between draft and non-draft states. Unfortunatley after many many years of asking for this, Illustrator still has not added this feature to text frame options.

The closest you can get is to draw a rectangle, click with the vertical type tool (But that will only allow you one character per line.)

![Screen Shot 2016-04-13 at 3.23.20 PM.png](/legacyfs/online/910043_Screen Shot 2016-04-13 at 3.23.20 PM.png)

You could do this with the align palette. You would need to select another element to align against (eg: a rectangle filled with none). You need to add an outline effect to the type, and in the align flyout menu turn ON use preview bounds.

![Screen Shot 2016-04-13 at 3.30.11 PM.png](/legacyfs/online/910045_Screen Shot 2016-04-13 at 3.30.11 PM.png) so if you want to be able to run them as separate runs, you’ll still need some way of communicating between them. one mechanism we provide for that is by serializing daml values as json through the --input-file and --output-file options to daml script. so in your case, you should make sure that the …