Results 1 to 4 of 4

Thread: iterate each line with random range

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    14

    iterate each line with random range

    i have two text file

    one is a.txt and another is b.txt

    content of a.txt is

    a
    b
    c
    d

    content of b.txt is

    1
    2
    3
    4
    5
    6
    7
    8
    9

    i want to process each a.txt line to random range of b.txt lines.

    for instance.

    Code:
        for each aa as String in a.txt
        
    		for bb as integer = 0 to b.txt.count - 1
         
    
    		end for
        
        end for
    so what i want to get result is like this one

    each a.txt line to random range of b.txt lines


    a12
    b3456
    c789

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: iterate each line with random range

    Create a Random object and then, each time you want a random number, call its Next method. It's the same regardless of what you intend to use the random number for. Of course, you're going to have to apply some appropriate limits or you'll get all lines in the second file associated with the first line in the first file more often than not. As for what those limits should be, that's nothing to do with programming because they would be the same as the limits you would use if you were doing the whole thing with pen and paper.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    14

    Re: iterate each line with random range

    Quote Originally Posted by jmcilhinney View Post
    Create a Random object and then, each time you want a random number, call its Next method. It's the same regardless of what you intend to use the random number for. Of course, you're going to have to apply some appropriate limits or you'll get all lines in the second file associated with the first line in the first file more often than not. As for what those limits should be, that's nothing to do with programming because they would be the same as the limits you would use if you were doing the whole thing with pen and paper.
    if you give me some more specific snippet or reference it would be very helpful for me.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: iterate each line with random range

    Quote Originally Posted by james27 View Post
    if you give me some more specific snippet or reference it would be very helpful for me.
    Why exactly a hopeful programmer needs to be shown how to do a web search, I'm not sure, but here's your reference anyway:

    http://lmgtfy.com/?q=vb.net+random+class
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width