August 1, 1998

Learn Control Array Bounds

You can use a control array’s UBound and LBound properties to determine how many controls are loaded. This code fills a string with the captions in the Label1 control array: For i = Label1.LBound To Label1.UBound txt = txt & Label1(i).Caption & “, “Next i

Close Forms Uniformly

To close forms uniformly, treat the system menu’s Close command and your File menu’s Exit command in the same manner. In your Exit command, simply unload the form. Let the form’s QueryUnload event handler see if it is safe to exit. If not, cancel the Exit by setting Cancel to

Create a new Project Template

Upon initialization, the VB5 IDE presents you with a list of project types, such as Standard EXE or ActiveX EXE. You can also create new project types yourself by creating templates and saving them to the Projects folder in your Templates directory. To find the Templates directory on your system,

Select Text-Box Contents on Entry Automatically

Many commercial apps select the contents of the text box automatically whenever it gets focus. You can do the same in your apps with a few VB statements. Invoke the SelStart and SelLength functions within a TextBox control’s GotFocus event: Private Sub Text1_GotFocus() Text1.SelStart = 0 Text1.SelLength = Len(Text1) End

Multiple Actions on One Event

To put two actions for one onmouseover=” ” event, just separate the two actions with a semicolon just like you would any two JavaScript statements. For example: OnChange=”alert(‘First Action’);alert(‘Second Action’)” However, if you have more than one action for an event, I recommend putting those actions into a function at

String Objects and C-strings: Caveats

The standard string class has a dual interface: it supports both C-style strings as well as string objects in various operations: const char text[] = “hello world”;string s = text; //initialization of string object with a C-style stringstring s2(s); //copy construction This duality allows backward compatibility with legacy code. It

Function Overloading

In order to overload a function, a different signature should be used for each overloaded version. A function signature consists of the list of types of its arguments as well as their order. Here’s a set of valid overloaded versions of a function named f: void f(char c, int i);void

Pre-Defined Macros

All C/C++ compilers define the following macros: __DATE__ //a literal containing the compilation date in the form “Apr 13 1998″__TIME__ //a literal containing the compilation time in the form “10:01:07″__FILE__ //a literal containing the name of the source file being compiled__LINE__ //a decimal integer containing the current line number in

No more posts to show