Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    May 2008
    Messaggi
    488

    "select case" dentro "for each"

    Ciao a tutti, vorrei mostrare a video solo i file che, trovandosi in una cartella scelta, hanno una certa estenzione e sto provando così :

    codice:
    DF = ""
        For Each whatever in fc
        Select Case Right(whatever.name,4)
        Case ".doc", ".txt"
            DF = "File di testo"
        Case ".xls"
            DF = "File di excel"
        Case ".pdf"
            DF = "File PDF"    
        Case else
        end Select
    %>
        <TD ALIGN=LEFT><FONT FACE="Arial" SIZE=2><%="<a href='"& Sotto_Cartella & "/" & whatever.Name & "'>"& whatever.Name & "</a>"%></FONT></TD>
        <TD ALIGN=LEFT><FONT FACE="Arial" SIZE=2><%=DF%></FONT></TD>
        </TR>
    <% next %>
    </TABLE>
    <TABLE CELLPADDING=4  BORDER=1 WIDTH=100%>
        <tr style="border-bottom-style: solid">
        <td colspan="2"><b>Nella directory corrente non sono presenti file scaricabili.</b></td>
        </tr>
    </TABLE>
    tuttavia così vengono comunque mostrati anche i file che hanno un'estenzione diversa da quella indicata, senza chiaramente alcuna desrizione.

    Come devo fare ?

  2. #2
    sbagli la logica!

    for each ....
    DF=""
    select case ....
    If DF<>"" Then ' visto che assegni DF solo a quelli che ti interessano...
    .....tabella
    End If
    Next

    Ultima modifica di optime; 18-10-2013 a 19:38

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2008
    Messaggi
    488
    Ok, scusa ma come faccio a non fargli ripetere la tabella o la frase tante volte per quanti file esistono nella cartella ?

    codice:
    <TABLE CELLPADDING=4  BORDER=1 WIDTH=100%>
    <% 
        For Each whatever in fc
        DF = ""
        Select Case Right(whatever.name,4)
        Case ".doc", ".txt"
            DF = "File di testo"
        Case ".xls"
            DF = "File di excel"
        Case ".pdf"
            DF = "File PDF"    
        Case else
        end Select
    %>
    <% if DF<>"" then %>
    <tr style="border-bottom-style: solid">
    <td colspan="2"><b>Elenco dei file presenti nella cartella "<u> <%=Sotto_Cartella%> </u>" :</b></td>
        </tr>
        <tr style="border-bottom-style: solid">
        <td><b>Nome File</b></td>
        <td><b>Tipo</b></td>
        </tr>
        <TR>
        <TD ALIGN=LEFT><FONT FACE="Arial" SIZE=2><%="<a href='"& Sotto_Cartella & "/" & whatever.Name & "'>"& whatever.Name & "</a>"%></FONT></TD>
        <TD ALIGN=LEFT><FONT FACE="Arial" SIZE=2><%=DF%></FONT></TD>
        </TR>
    <% else %>
    <tr style="border-bottom-style: solid">
    <td colspan="2"><b>Nella cartella "<u> <%=Sotto_Cartella%> </u>" non sono presenti file da scaricare .</b></td>
        </tr>
    <% end if %>
    <% next %>    
    </TABLE>

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.