Sign in to follow this  
Followers 0
Doggie

[vb] Simple Quick Codes

2 posts in this topic

Display the Current Time

Simply put a label control

in form load event put

Private Sub Form_Load()
labelname.caption = time
End Sub

and if u want it to be updated every second add timer and label

Private Sub Timer1_Timer()
labelname.caption = time
End Sub

make sure u make the timer interval = 1

0

Share this post


Link to post
Share on other sites

File System

Like to know how to do such things as delete file(s) and directory(s)? Even create directories etc?

Well, take a look what i'm about to write :)

Directory(s)

To create a directory, simply use this code;

VBA.FileSystem.MkDir "driveletter:\directoryname"

eg VBA.FileSystem.MkDir "C:\dogs"

simple huh? :rolleyes:

Maybe u'd like to remove a specifyed directory?

VBA.FileSystem.RmDir "driveletter:\directoryname"

same type of method with the drive letter and dir name

just a note about this. To avoid errors with this, add the follow to the code;

On Error GoTo errLog
VBA.FileSystem.RmDir "c:\rabbits" ' This is an example say if it didn't exist so no need to add this :P
errLog:
If Err.Number = 76 Then
MsgBox "Directory doesn't exist"
End If

Time to use the On Error Goto statement. The example states on an error goto ErrLog

What this means if the error number = 76, simply mean if the directory doesn't exist, a msgbox will appear saying so.

adding more code soon, please be patient :D

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.