Visual Basic
  Home arrow Visual Basic arrow Page 4 - Creating an HTML File List with VB
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC

Creating an HTML File List with VB
By: Tim Haight
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 84
    2004-01-05

    Table of Contents:
  • Creating an HTML File List with VB
  • Setting Up Your Program
  • Coding the Program
  • Opening the Dir.txt File and Creating the HTML File
  • Compiling the File and Wrapping Up

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Creating an HTML File List with VB - Opening the Dir.txt File and Creating the HTML File


    (Page 4 of 5 )

    To create the catalog HTML file:

    1. Create the HTML headings
    2. The dir file will have to be opened for input
    3. Read in a line
    4. Output the line in HTML format
    5. Skip to the next record
    6. Do 3-4 until finished
    7. Create the end of the HTML file
    8. Close the files

    From the above pseudo code, you can tell there will be a file input, a file output, and a loop.

    The subroutine will look like this


    Private Sub cmdCatalog_Click()
    On Error GoTo Err_cmdCatalog_Click
      
    'run directory listing
      '
    put the path in the shell command where you put the dir.bat file
      Dim RetVal
      RetVal 
    Shell(txtLocation "dir.bat"1)    ' Run dir.bat
      '
    open file for input and output
      
    'change path for your system
      Open txtLocation & "dir.txt" For Input As #1
      Open txtLocation & "catalog.htm" For Output As #2
      
      '
    create HTML headings
      
    Print #2, "<HTML><HEAD><TITLE>MY Pictures</TITLE></HEAD><BODY>"
      Print #2, "<center><h1>My Pictures</h1></center>"
      Print #2, "<OL>"
      'create loop, open file
      Do Until EOF(1)
      
        'get line from file
        Input #1, txtFile
      
        'output line to catalog
        Print #2, "<LI>"
        Print #2, "<a href='" & txtFile & "'>" & txtFile & "</a><br>"
        Print #2, "</LI>"
      Loop
      
      'create HTML end
      Print #2, "</OL>"
      Print #2, "</BODY></HTML>"
      
      'close files
      Close #1
      Close #2
      
    Exit_cmdCatalog_Click:
        Exit Sub
    Err_cmdCatalog_Click:
        MsgBox Err
    .Description
        Resume Exit_cmdCatalog_Click
    End Sub

    More Visual Basic Articles
    More By Tim Haight


     

    VISUAL BASIC ARTICLES

    - Developing an XML Web Service Using Visual S...
    - Creating an HTML File List with VB
    - Fun with Email: VB6, CDO, MAPI, and a Remote...
    - Extranet/Intranet Dictionary Cracker in VB
    - Finding Default App Icons With Visual Basic
    - Registry Fever With Visual Basic
    - Implementing An ADO Data Control With VB6
    - Printing With Visual Basic
    - MSMQ Part 1/2: Architecture and Simple Imple...
    - Magnifying The Desktop With Visual Basic
    - Sending Email With MAPI Components in Visual...
    - Two Person Chat With The Winsock Control And...
    - A Real-Time ActiveX News Control
    - Accessing the Windows API in Visual Basic







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT