Fetstil Fetstil Kursiv Understrykning linje färgläggning tabellverk Punktlista Nummerlista Vänster Centrerat högerställt Utfyllt Länk Bild htmlmode
  • Forum & Blog
    • Forum - översikt
      • .Net
        • asp.net generellt
        • c#
        • vb.net
        • f#
        • silverlight
        • microsoft surface
        • visual studio .net
      • databaser
        • sql-server
        • databaser
        • access
        • mysql
      • mjukvara klient
        • datorer och komponenter
        • nätverk, lan/wan
        • operativsystem
        • programvaror
        • säkerhet, inställningar
        • windows server
        • allmänt
        • crystal reports
        • exchange/outlook
        • microsoft office
      • mjukvara server
        • active directory
        • biztalk
        • exchange
        • linux
        • sharepoint
        • webbservers
        • sql server
      • appar (win/mobil)
      • programspråk
        • c++
        • delphi
        • java
        • quick basic
        • visual basic
      • scripting
        • asp 3.0
        • flash actionscript
        • html css
        • javascript
        • php
        • regular expresssion
        • xml
      • spel och grafik
        • DirectX
        • Spel och grafik
      • ledning
        • Arkitektur
        • Systemutveckling
        • krav och test
        • projektledning
        • ledningsfrågor
      • vb-sektioner
        • activeX
        • windows api
        • elektronik
        • internet
        • komponenter
        • nätverk
        • operativsystem
      • övriga forum
        • arbete karriär
        • erbjuda uppdrag och tjänster
        • juridiska frågor
        • köp och sälj
        • matematik och fysik
        • intern information
        • skrivklåda
        • webb-operatörer
    • Posta inlägg i forumet
    • Chatta med andra
  • Konto
    • Medlemssida
    • Byta lösenord
    • Bli bonsumedlem
    • iMail
  • Material
    • Tips & tricks
    • Artiklar
    • Programarkiv
  • JOBB
  • Student
    • Studentlicenser
  • KONTAKT
    • Om pellesoft
    • Grundare
    • Kontakta oss
    • Annonsering
    • Partners
    • Felanmälan
  • Logga in

Hem / Forum översikt / inlägg

Posta nytt inlägg


Omvänd lista.

Postades av 2004-01-29 14:56:03 - Johan Hjort, i forum asp - allmänt, Tråden har 4 Kommentarer och lästs av 415 personer

Den här koden

<code>
Dim objFSO, objFile
Dim sMapPath, objFolder

'Create File System Object to get list of files
Set objFSO = CreateObject("Scripting.FileSystemObject")


'Get The path for the web page and its dir, change this setting to view different directories!
sMapPath = server.mapPath("data/") ' this means the current directory

'Set the object folder to the mapped path
Set objFolder = objFSO.GetFolder(sMapPath)
' Then for each file in the object we loop through and print the file and when it was last modified
For Each objFile in objFolder.Files


Response.Write "" ' Print out a link to the file
Response.write Left(objFile.Name, Len(objFile.Name) - 4) ' the file name and its date
Response.write "
<br>" & vbCrlf ' close the tags

Next ' Loop back

' Clear the objects
Set objFSO = Nothing
Set objFolder = Nothing
</code>

Skriver ut det här
2002-05-06
2003-05-07
2003-12-10
2004-01-23

Nu vill jag ha det omvänt, så att det blir
2004-01-23
2003-12-10
2003-05-07
2002-05-06

Hur gör jag?

Tack på förhand :)


Svara

Sv: Omvänd lista.

Postades av 2004-01-29 15:20:58 - Thomas Roman

<code>
Dim objFSO, objFile
Dim sMapPath, objFolder
Dim Links(0)

'Create File System Object to get list of files
Set objFSO = CreateObject("Scripting.FileSystemObject")


'Get The path for the web page and its dir, change this setting to view different directories!
sMapPath = server.mapPath("data/") ' this means the current directory

'Set the object folder to the mapped path
Set objFolder = objFSO.GetFolder(sMapPath)
' Then for each file in the object we loop through and print the file and when it was last modified

For Each objFile in objFolder.Files
x = UBound(Links) +1
ReDim Preserve Links(x)

Links(x) = "" ' Print out a link to the file
Links(x) = Links(x) & Left(objFile.Name, Len(objFile.Name) - 4) ' the file name and its date
Links(x) = Links(x) & "
<br>" ' close the tags
Next ' Loop back

For i = UBound(Links) To 1 Step -1
Response.Write Links(i)
Next 'i

' Clear the objects
Set objFSO = Nothing
Set objFolder = Nothing
</code>

Har inte testat koden själv, men den borde fungera...


Thomas


Svara

Sv: Omvänd lista.

Postades av 2004-01-29 15:22:55 - Johan Hjort

Jag får

Microsoft VBScript runtime error '800a000a'

This array is fixed or temporarily locked

/diary/index.asp, line 71


Svara

Sv: Omvänd lista.

Postades av 2004-01-29 15:23:59 - Thomas Roman

Ok testa:

<code>
Dim objFSO, objFile
Dim sMapPath, objFolder
Dim Links()

'Create File System Object to get list of files
Set objFSO = CreateObject("Scripting.FileSystemObject")


'Get The path for the web page and its dir, change this setting to view different directories!
sMapPath = server.mapPath("data/") ' this means the current directory

'Set the object folder to the mapped path
Set objFolder = objFSO.GetFolder(sMapPath)
' Then for each file in the object we loop through and print the file and when it was last modified

ReDim Links(0)
For Each objFile in objFolder.Files
x = UBound(Links) +1
ReDim Preserve Links(x)

Links(x) = "" ' Print out a link to the file
Links(x) = Links(x) & Left(objFile.Name, Len(objFile.Name) - 4) ' the file name and its date
Links(x) = Links(x) & "
<br>" ' close the tags
Next ' Loop back

For i = UBound(Links) To 1 Step -1
Response.Write Links(i)
Next 'i

' Clear the objects
Set objFSO = Nothing
Set objFolder = Nothing
</code>


Svara

Sv: Omvänd lista.

Postades av 2004-01-29 15:24:54 - Johan Hjort

Det funkade perfekt. Tack så mycket!


Svara

Nyligen

  • 08:28 Butiksskyltar: Hur upplever utbude
  • 22:31 Slappna av
  • 19:55 kick-off med fokus på hälsa?
  • 19:53 kick-off med fokus på hälsa?
  • 16:24 Föreslå en skönhetsklinik online
  • 16:23 Föreslå en skönhetsklinik online
  • 18:42 Hvor finder man håndlavede lamper
  • 18:41 Hvor finder man håndlavede lamper

Sidor

  • Hem
  • Bli bonusmedlem
  • Läs artiklar
  • Chatta med andra
  • Sök och erbjud jobb
  • Kontakta oss
  • Studentlicenser
  • Skriv en artikel

Statistik

Antal besökare:
Antal medlemmar:
Antal inlägg:
Online:
På chatten:
4 570 791
27 960
271 761
5 962
0

Kontakta oss

Frågor runt konsultation, rådgivning, uppdrag, rekrytering, annonsering och övriga ärenden. Ring: 0730-88 22 24 | pelle@pellesoft.se

© 1986-2013 PelleSoft AB. Last Build 4.1.7169.18070 (2019-08-18 10:02:21) 4.0.30319.42000
  • Om
  • Kontakta
  • Regler
  • Cookies