You 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.
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:
Create the HTML headings
The dir file will have to be opened for input
Read in a line
Output the line in HTML format
Skip to the next record
Do 3-4 until finished
Create the end of the HTML file
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)