Read random file?

Jourdan
09-14-2009, 01:58 PM
Hi, I'm a beginner, can someone help me?

I want to make my application read a random text file in a folder. For example in a folder c:\data\ there's: a.txt, b.txt, c.txt. How do My app read it randomly?

thanks in advance

kassyopeia
09-14-2009, 03:05 PM
This contains some of what you'd need:

Const nFiles = 3

'random number between 0 and (nFiles - 1)
Randomize
Dim nFileRandom As Long: nFileRandom = Int(nFiles * Rnd)

'letter corresponding to that number
Debug.Print Chr$(Asc("a") + nFileRandom)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum