devxlogo

Tip Bank

Used Bytes in a Directory

This function returns the number of bytes used on the directory: Function DirUsedBytes(ByVal dirName As _ String) As LongDim FileName As StringDim FileSize As Currency’ add a backslash if not

Get Useful Disk Information

This function returns the hard disk free bytes, total bytes, percentage of free bytes, and used space. Before calling the function, set the first field of the DISKSPACEINFO structure (“RootPath”)

Trapping a Double Click for a Toolbar Button

VB4 supports the built-in Win95 Toolbar control, which allows users to add Buttons to the toolbar. The buttonhas a ButtonClick event, but if you want to trap a double-click, there

Test for “File Exist” the Right Way

Dir$ raises a runtime error if you supply it an invalid drive. For example, Dir$ (“d:winhimems.sys”) crashes ifdrive d: doesn’t exist. To check if a file exists, add an error

Procedures that Act on a Group of Controls

You can use the almost-forgotten ability of Visual Basic to have a function or sub with an undeterminednumber of arguments do something to a set of controls. For example, you

Put VB Intrinsic Constants to Good Use

I’ve seen several tips using numeric values instead of the corresponding Visual Basic constants. Always usethe Visual Basic predefined constants. For example, you can set up a message box using

Encrypted Passwords

These two small, simple, and effective functions easily encrypt/decrypt a text password. The functions taketwo parameters: a number in the range of 1 to 10 used to alternatively shift up