%
Function GetRandomPic()
dim strThisFileName
dim strThisFolderName
dim strOutput
dim intRandNum
dim strFileName
dim strFolder
dim intCount
strThisFileName = "randpic.asp"
strFolder = "/Images/"
Dim fs, f, fld, fl
Set fs = Server.CreateObject("Scripting.FileSystemObject")
strThisFolderName = replace(server.mappath(strFolder & strThisFileName), strThisFileName, "",1,-1,1)
Set fld = fs.GetFolder(strThisFolderName)
Set f = fld.Files
redim arrFiles(1)
intCount = 0
For Each fl In f
strFileName = fl.Name
if strFileName <> strThisFileName then
'Exclude files here...line below will exclude the thumbnails
if ucase(right(strFileName, 5)) <> "T.JPG" then
'response.write "
" & strFilename & "|" & strThisFileName
if intCount > ubound(arrFiles) then
redim preserve arrFiles(intCount)
end if
arrFiles(intCount) = strFileName
intCount = intCount +1
end if
end if
Next
dim iSound
iSound = gGetRandNumber(0,ubound(arrFiles)-1)
GetRandomPic = strFolder & arrFiles(iSound)
set fs = nothing
set fld = nothing
set f = nothing
set fl = nothing
End Function
function gGetRandNumber(MinVal, MaxVal)
RANDOMIZE TIMER
dim intRange
dim intTemp
intRange = MaxVal - MinVal
intTemp = Round((Rnd() * intRange), 0)
gGetRandNumber = MinVal + intTemp
'response.write "
1:" & MinVal
'response.write "
2:" & MaxVal
'response.write "
3:" & gGetRandNumber
end function
%>