Home arrow Visual Basic arrow Page 4 - Creating an HTML File List with VB

Creating an HTML File List with VB

Visual BasicYou just got that shiny new digital camera, and then you downloaded a bunch of digital pictures to your computer. Next you want to create a simple Hypertext Markup Language (HTML) file so that you can burn the picture and HTML files to a CD that you can send to all your friends and family.  How do you do this without having to manually code the HTML file? The following instructions will show you how. 

Author Info:
By: Tim Haight
Rating: 4 stars4 stars4 stars4 stars4 stars / 101
January 05, 2004
  1. · Creating an HTML File List with VB
  2. · Setting Up Your Program
  3. · Coding the Program
  4. · Opening the Dir.txt File and Creating the HTML File
  5. · Compiling the File and Wrapping Up

print this article

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
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>"
  'create HTML end
  Print #2, "</OL>"
  Print #2, "</BODY></HTML>"
  'close files
  Close #1
  Close #2
    Exit Sub
    MsgBox Err
    Resume Exit_cmdCatalog_Click
End Sub

blog comments powered by Disqus

- 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

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials