|
-
Dec 2nd, 2004, 12:17 PM
#1
Thread Starter
Hyperactive Member
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
-
Dec 2nd, 2004, 12:22 PM
#2
Hyperactive Member
VB Code:
Private Sub Form_Load()
Randomize Timer
Open "C:\text\" & (Int(Rnd*10)+1) & ".txt" For Input As 1
Text1.Text = Input(LOF(1), 1)
Close #1
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
-
Dec 2nd, 2004, 12:33 PM
#3
Thread Starter
Hyperactive Member
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
-
Dec 2nd, 2004, 01:07 PM
#4
Hyperactive Member
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
-
Dec 2nd, 2004, 01:13 PM
#5
Thread Starter
Hyperactive Member
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!
-
Dec 2nd, 2004, 01:17 PM
#6
Hyperactive Member
Try:
VB Code:
Private Sub Form_Load()
Randomize Timer
Open "C:\text\" & (Int(Rnd*10)+1) & ".txt" For Input As 1
Text1.Text = Input(LOF(1)-2, 1)
Close #1
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|