Newsletter Tips & Code - May 2000
These tips were extracted from the May 2000 issue of the Visual Basic Explorer
newsletter and were submitted by John Smiley. Be sure to check out John's other
tutorials in the tutorials section or check out his website here.
You can direct any questions, comments or suggestions to the VB Forums section
of this site. Many of the more interesting or frequently asked questions will
end up in one of our newsletter issues.
'-------------------------------------------
Trying to change the BackColor property of a command button?
You first need to change the Style Property to Graphical---otherwise the BackColor of the Command
Button remains as is.
'-------------------------------------------
Dollar sign Functions--what are they?
Ever wonder about those functions ending in a dollar sign? If you are running VB5 or VB6, you might not
even see them mentioned in VB Help.
In VB, there are a number of functions that have a dollar sign version---such as Left$, Right$ and Case$
What's the difference between the functions Left$ and Left?
For those of you not familiar with functions, functions return a value to the procedure that calls them. This
return value can be of a particular data type, and dollar sign functions return a value of type String. The
non-dollar sign versions return a Variant Data Type.
Which one should you choose to use?
Dollar sign functions run faster than non dollar sign functions, so in general, it's a good choice to use them.
Is there ever a reason to use the non-dollar sign function?
Yes---if there's a possibility that the function will encounter a Null character in its argument string, you
need to use the non-dollar sign version--otherwise the function will bomb. For instance, in this code
Form1.Print Left(string1, 1)
Form1.Print Left$(string1, 1)
both Left and Left$ will return the left-most character of the string. However, if string1 contains a Null
character, Left$ will bomb---however, Left will work fine.
'-------------------------------------------
Another instance of your program running?
If you want to ensure that only one instance of your program runs at one time, use the App object's
PrevInstance property to determine if another instance of your program is already running---if it is, you can
end the new instance, like this:
If App.PrevInstance = True Then
Unload Me
End
End If
'-------------------------------------------
Trying to compile a Project using the VB Learning Edition?
You'll need to purchase either the Visual Basic Standard, Professional or Enterprise edition in order to
compile your program into an executable.
'-------------------------------------------
Your compiled program won't run on a friend's PC
You probably gave your friend just the compiled executable file.
Visual Basic programs need to have the Visual Basic runtime DLL installed on the PC also---plus some
other support files.
The easiest way to do this is to run the Package and Deployment Wizard in Visual Basic to create a Setup
package.
Then all you need to do is give the diskette(s) to your friend, and have them run the Setup program found
on Disk 1---the same they would do for any other Windows program.
This way both your executable, and the Visual Basic runtime DLL and support files are installed.
'-------------------------------------------
Looking for a free version of VB?
Microsoft made a free version of VB5 called the Control Creation Edition available for download from
their website. It's still there, and you can find it at this URL:
http://msdn.microsoft.com/vbasic/downloads/cce/
There is no free version of Visual Basic 6 available from Microsoft. However, there are several Visual
Basic books (including my first book, Learn to Program with Visual Basic 6) on the market that come with
the Visual Basic Working Model Edition--which is a surprisingly full featured version of Visual Basic (no,
you can't compile programs with it)