Search Tools Links Login

File Logging Module

This is a simple module that will allow you to log events from within your program to a text file. This is more of a string handling demo, but could be useful as a starting point for something bigger.

If you're like me, you like to know what is going in your application. This information comes in handy if and when something goes wrong. You'll have some idea where execution stopped, and why.

I popped this together more as a demonstration of how to work with strings and variables, but it does perform a useful function.

Some high points of this script are:

It should be noted (and it is in the comments inside the module) that there is a simpler way of creating ISO8601 date and time data. By using the built-in Format$ function of VB6, the string can be built in one line.

The syntax for creating and ISO8601 date is:

ISO8601Date = Format$(Now, "yyyy-mm-dd")

If you want to create a date/time string, simply extend it:

ISO8601DateTime = Format$(Now, "yyyy-mm-dd") & " " & Format$(Now,"hh:mm:ss")

Can you find other cool ways of using the format$ function? Or maybe you have a better method? Give a shout in the comments, or start a thread in the forums!

About this post

Posted: 2018-06-15
By: vb6boy
Viewed: 1,020 times


Visual Basic 6

Posted: 6/15/2018 9:55:53 AM
Size: 1,408 bytes

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.