Results 1 to 6 of 6

Thread: Ramdomize

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Posts
    305

    Ramdomize

    Hey how can i ramdoize each file it will read the infor from to the text box thanks?maybe somit like this

    Code:
    Private Sub Form_Load()
    Open "C:\text\& rnd &.txt " For Input As 1
    
    Text1.Text = Input(LOF(1), 1)
    End Sub

    in the folder text there is about 10 text files and i want it to ramdomize what ones it reads into the txt box thanks

  2. #2
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439
    VB Code:
    1. Private Sub Form_Load()
    2. Randomize Timer
    3. Open "C:\text\" & (Int(Rnd*10)+1) & ".txt" For Input As 1
    4. Text1.Text = Input(LOF(1), 1)
    5. Close #1
    6. End Sub

    Look up the Randomize statement and the Rnd function in VB's help for more information on this.
    "I don't want to live alone until I'm married" - M.M.R.P

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Posts
    305
    hey thanks gr8 work one more problem wen loading the data i get 2 lil funni chars example "name||"some lil bloks like that how can i just load the data wiv out any funny chars at the end thanks

  4. #4
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439
    those two blocks represent characters with ASCII codes 10 and 13 respectively. Those make up the character/line return. Those two characters are the same thing as pressing your "Enter" key. The blocks show up because the textbox's MultiLine property is set to false. Set that property to true and the file will display correctly.
    "I don't want to live alone until I'm married" - M.M.R.P

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Posts
    305
    and when i do that it adds few blank spaces lol so its bugs up but if i delete them to the last word then it works...is there any way on the last letter in the txt box to clear all the stuff wats after that thanks!

  6. #6
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439
    Try:
    VB Code:
    1. Private Sub Form_Load()
    2. Randomize Timer
    3. Open "C:\text\" & (Int(Rnd*10)+1) & ".txt" For Input As 1
    4. Text1.Text = Input(LOF(1)-2, 1)
    5. Close #1
    6. End Sub
    "I don't want to live alone until I'm married" - M.M.R.P

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