DAOTableToHTML

By | 2002-06-01

Convert a database table to HTML

Original Author: Vincent Zack

Inputs

DAO Recordset Object

Assumptions

A reference to DAO x.x Object Library

Returns

String

Code

Const T1 = vbTab
Const T2 = T1 & T1
Const TR = T1 & ""
Const TD = ""
Const TDEND = ""
Const TABLESTART = ""
Const TABLEEND = "

"
Function HTMLTable(dbRecord As Recordset) As String
Dim strReturn As String
Dim Fld As Field
On Error GoTo Return_Zero
strReturn = strReturn & TABLESTART & vbCrLf
strReturn = strReturn & TR
For Each Fld In dbRecord.Fields
  strReturn = strReturn & TD & Fld.Name & TDEND
Next Fld
strReturn = strReturn & vbCrLf
dbRecord.MoveFirst
While Not dbRecord.EOF
  strReturn = strReturn & TR
  For Each Fld In dbRecord.Fields
    strReturn = strReturn & TD & Fld.Value & TDEND
  Next Fld
  strReturn = strReturn & vbCrLf
dbRecord.MoveNext
Wend
strReturn = strReturn & TABLEEND
Return_Zero:
HTMLTable = strReturn
End Function

Date:2002-06-01

Migrated:Not Migrated

*** Destroy a file without getting error! ***

This DOES use the kill function, but when you use this it actually opens the file you want to destroy, cleans it out, then deletes it so you don’t get any error because of sensitive data!

Original Author: Matt Evans

Inputs

File To Delete

Assumptions

Make sure not to delete win.com, win.ini, config.sys, himem.sys, autoexec.bat or any of those files, lol ;D

Returns

No more file

Code

Sub DestroyFile(sFileName As String)
  Dim Block1 As String, Block2 As String, Blocks As Long
  Dim hFileHandle As Integer, iLoop As Long, offset As Long
  'Create two buffers with a specified 'wipe-out' characters
  Const BLOCKSIZE = 4096
  Block1 = String(BLOCKSIZE, "X")
  Block2 = String(BLOCKSIZE, " ")
  'Overwrite the file contents with the wipe-out characters
  hFileHandle = FreeFile
  Open sFileName For Binary As hFileHandle
    Blocks = (LOF(hFileHandle) BLOCKSIZE) + 1
    For iLoop = 1 To Blocks
      offset = Seek(hFileHandle)
      Put hFileHandle, , Block1
      Put hFileHandle, offset, Block2
    Next iLoop
  Close hFileHandle
  'Now you can delete the file, which contains no sensitive data
  Kill sFileName
End Sub

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.