devxlogo

We are an award-winning tech entrepreneurship website where trusted experts can provide value globally.

Since 1998, DevX has helped people start businesses, build websites, and provide enterprise technology to people globally. Interviewing the likes of Microsoft’s co-founder, Steve Ballmer, the publication brings comprehensive, reliable, and accessible insights to the Internet.

devxlogo

Trusted for 26 years

Over 30K Articles

1M+ Readers

Expert-reviewed

10K+ Tech Terms

As seen in:

microsoft logo
business_insider_logo
wired_logo
berkley
arstechnica_logo
hackernoon

The Latest

Current Computer Name on Windows 95/NT

You often want to know the name of the current computer running Windows 95 or Windows NT in your VB program. Use this simple wrapper function of a kernel32.dll API

Show Fonts as you Select Them

To let a user change a font name, load all the fonts into a combo box: Private Sub Form_Load() ‘ Determine the number of screen ‘ fonts. For I =

Shortcuts for the VB Environment

1) In VB5, pressing Ctrl-F3 when the cursor is over a word automatically searches to the next occurrenceof that word, bypassing the search dialog. You need to be past the

Get all Matching Files in a Directory Structure

Because this code doesn’t use an API, you can easily port it between 16- and 32- bit applications. TheDirWalk procedure lets you search an entire directory structure starting at whatever

Trap Right-Clicks on TreeView’s Nodes

The TreeView control gives your apps a good Windows 95 look and feel. However, the VB manual doesn’texplain how to trap the right mouse button in a node. The Treeview_MouseDown

Getting UserID on Windows 95 and NT

You often want to get the user ID of the current user on the machine running Windows 95 or Windows NT.Use this simple wrapper function of an API function to

Run VB Using the Sendto Menu

Adding a “Shortcut to VB.exe” and “Shortcut to VB32.exe” to your “Send To” menu lets you right-click onany VBP project and open it with your choice of VB4 16/32 or

Fixing a Proper Case Tip

If you use the left arrow key to go back to the beginning of a word and then enter a letter, you get twouppercase letters. Use this code, which takes

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

Use a Collection to Filter out Duplicate Values

This code illustrates how to use a Collection to automatically generate a unique set of values from a set of datacontaining duplicates. In this example, scan a string array and

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

Constituent Controls are Private to UserControl Modules

You cannot directly access constituent controls on a UserControl component from another module of the sameproject. Constituent controls behave differently from controls on forms, which you can access from any

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

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

Create “Remotely Controllable” Forms

Sometimes I need to control a VB form while focus is on another one. For example, I want form B to beresized when I press the “OK” button on form

Run Automation Manager as a Hidden Task

If you use OLE Remote Automation, you must start the Automation Manager on the server computer beforeany OLE remote communication occurs. By default, this application is visible, but you can

Better Scrolling Images

I enjoyed Joel Paula’s “Scrollable Viewport for a Picture” tip [“101 Tech Tips for VB Developers,” Supplementto the February 1997 issue of VBPJ, page 12], and I’d like to make

Problems with Popup Menus

If you use popup menus in your applications, you should be aware of a bug present in VB4 16/32 and VB5. Ifyou have two forms and the first one shows

Save Form Position and Size Using SaveSetting

SaveSetting and GetSetting make writing application settings a breeze. These two utility functions retrieve andstore the current forms position: Public Sub FormPosition_Get(F As Form)’ Retrieve Form F’s position from an

Properties that Behave Like Text and Caption

If you build an ActiveX control that exposes a Text- or Caption-like property, even under different names, you should modify its attributes in the Procedure Attribute dialog box after expanding

GoSubs are Slow in Compiled Programs

Because GoSubs make for less structured programming, many programmers avoid them. If you compile yourVB5 applications to native code, you have one more reason to stay away from them because,

Speed up your Code Using Choose

You can often use Choose to replace an array and build tables of results evaluated at compile-time instead ofrun time. For instance, if you need to evaluate the factorial of

Compact Your Code Using IIF and Switch

You can often replace an If…Then…Else block with a more compact IIf function: ‘ returns the max of two valuesmaxValue = IIf(first >= second, _ first, second) Switch is a

Combine Default with Other Attributes

When building an ActiveX control, you can set a default property or method using the Procedure Attributesdialog box, after clicking on the Advanced button. However, if your default property also

“Array” is not a Valid Variable Name Anymore

If you, like me, often used the “array” name for variables, you must revise your code when porting yourapplications to Visual Basic 5.0. This name has become a reserved keyword

AutoSelect Text Box Contents

Users often find it faster to retype the entire contents of a text box rather than position the cursor within the data, and then edit the data. This is especially