devxlogo

Tip Bank

Append a String to a Text Box

Use this code to cause a TextBox control to automatically scroll down as you concatenate new text: ””Select the end of the text MyTextBox.SelStart = Len(MyTextBox.Text)””Put the new text thereMyTextBox.SelText

Use

Use an ampersand (&) instead of a plus sign (+) when concatenatingstrings. Depending on the data type of the operands, using the plus signmay result in an addition.

Watch What You Pass To Your OLE Servers

Don’t use any objects in the Visual Basic object library as parametersor return values for exposed properties or methods in public classes. Theseobjects are not intended to be used from

Use The Most Specific Type Available

Instead of declaring an object As Object, use the specific object type, such as CTask. This improves performance by minimizing the OLE lookup requirements.

Optimize Label Creation

Place one label on your form, tailor its properties (such as left-alignand autosize), and copy and paste it to create the rest of your labels.

Be Aware, It’s Not C!

VB developers that program with C language might be confused by a feature in the language. Consider thiscode: Dim x As IntegerDim y As IntegerDim z As Integer x =

Initializing An In-Process OLE Server DLL

Start the in-process OLE server using a Sub Main procedure. Includeall server initialization code in the Sub Main procedure. Don’t show formsfrom the Sub Main procedure and don’t use the

Set All Object Variables To Nothing

Do set all object variables to nothing before ending the application.When the End statement is executed in the OLE client application, the OLEserver is shut down and the Terminate events