Ir para conteúdo
Fórum Có
Entre para seguir isso  
Ted k'

Imagens Aleatórias : Randomize

Recommended Posts

Mais um randomize de Imagens adaptado para as necessidade básicas:

<%@ Language="VBScript" %>
<% Option Explicit %>
  Function RandomDeImagens(strPath,strDefault)
        On Error Resume Next
        Randomize Timer

        Dim ObjDeFSO, objFolder, ObjDaPasta, ObjPasta02
        Dim StrPastas, StrImagens, StrBase, StrPasta

        Const strValid = ".gif.jpg.png"

        If Right(strPath,1) <> Chr(47) Then strPath = strPath & Chr(47)
        StrBase = Server.MapPath(strPath)
        Set ObjDeFSO = Server.CreateObject("Scripting.FileSystemObject")
        Set objFolder = ObjDeFSO.GetFolder(StrBase)
        Set ObjDaPasta = objFolder.Files

        For Each ObjPasta02 In ObjDaPasta
          StrPasta = LCase(ObjPasta02.Name)
          If Instr(strValid,Right(StrPasta,4)) Then
                StrPastas = StrPastas & StrPasta & VbTab
          End If

        StrImagens = Split(StrPastas,VbTab)
        If UBound(StrImagens) > 1 Then
          RandomDeImagens = strPath & StrImagens(Int(Rnd(1)*UBound(StrImagens)))
          RandomDeImagens = strDefault
        End If

  End Function

<div align="center">
<table border="1" bordercolor="#000000">
        <td bgcolor="#ffffff">
          <!-- a pasta developercenter é relacionanda a sua pasta principal -->
          <img src="<%=RandomDeImagens("images/","/developercenter/images/default.gif")%>">

Compartilhar este post

Link para o post
Compartilhar em outros sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.


×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Entre para seguir isso  

  • Criar Novo...