Results 1 to 3 of 3

Thread: read lines from a text file randomly

  1. #1
    aroshlakshan is offline VB.NET Forum Newbie
    .NET Framework
    .NET 2.0
    Join Date
    Jan 2011
    Posts
    4
    Reputation
    0

    read lines from a text file randomly

    i wanna read lines from a text file randomly until all the lines are read & wanna set a time interval in each two words apart. can anyone please think a piece of code to do that in vb.net?? thanks...!

  2. #2
    JuggaloBrotha's Avatar
    JuggaloBrotha is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Jun 2004
    Location
    Lansing, MI; USA
    Posts
    4,328
    Reputation
    959
    Well considering you can't just read them from the file randomly, you can read the entire contents into a String variable, then use a List(Of String) add all of the lines (Use the variable's Split() method) into the List(Of String) then randomly read each element from the List(Of String).
    Currently using: VS 2010 Ultimate on Win7 Ultimate x64.


  3. #3
    LeonR is offline VB.NET Forum Fanatic
    .NET Framework
    .NET 4.0
    Join Date
    Nov 2006
    Location
    UK
    Posts
    141
    Reputation
    84
    As said above, you could populate a variable and then randomize a number to specify which element to read from the array, if you make sure that you delete the element afterwards and then change the randomize range it will be more efficent and wont have to error check to see if its already read that line? Just a thought!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking