VB FAQ





What can I do with C-Sharpener For VB?

C-Sharpener For VB can automatically convert VB to C# (or as some developers like to spell it VB 2 CSharp  ). It is a Visual Studio .NET addin and converts all VB.NET project related files including the project file itself.



What's the difference between MODAL and MODELESS forms?

MODAL forms are forms which require user input before any other actions can be taken place. MODELESS forms are those which are shown but do not require immediate user input



When/Why should I use Option Explicit?

Option Explicit forces you to declare all variables before using them. Opinions vary greatly on this subject. The main reason to use the OPTION EXPLICIT statement at the top of all modules is to minimize the amount of bugs introduced into your code by misspelling a variable name.



Why does everybody say I should save in TEXT not BINARY?

If you save the source and the project as text, it becomes ASCII (or really, ANSI) code that you can edit with any text editor or (if you are careful when you save) word processor. If you save in binary, only the VB development environment, current or later versions, will understand the code.



Is the Variant type slower than using other variable types?

Generally, yes, if we are talking numeric variable types. The Variant type also increases memory overhead. To test the speed difference, try the following piece of code in something like a button_click event and keep the debug window on the screen:



What is passing by reference?

Arguments are either passed by reference or by value. When they are passed by value, they cannot be changed by the procedure or function they are passed to. They can be altered when passed by reference, since passing by reference is just passing the address.



 I get a "file not found" error on the IIF function when I distribute by program. Uh?

There's a documentation error in VB 3.0, since the manual does not tell you that the IIF function requires the file MSAFINX.DLL to be distributed with your application. No, IIF is not really a financial function so go figure.



 Is there any way to pass a variable to a form apart from using global variables?

The standard workaround is to put an invisible text box (or caption or any other control that suits your use.) on the target form and access it by Form.textbox = "value". Then you can use the Change event of that control to do anything you want in that form.



 Is there a way to break long lines in VB code?

Visual Basic 4.0 and above breaks any lines by placing " _" (space+underscore) at the end of the line which will continue below. You cannot break inside literals (ie. quotes). This was a much welcome addition!



How do I prevent multiple instances of my program?

In VB 3 and above, the property App.PrevInstance is set to True if an older instance of the program already exist.



 How do I speed up control property access?

Instead of using a property in a loop, you will be better off using a normal variable in the loop and then assign the variable once to the property afterwards. Also, when reading a property, you should read it once into a variable instead of using it in a loop.



What is the Windows API?

The Windows API (Application Program Interface) is a collection of Dynamic-Link Libraries (DLLs) that do most of the common things in Windows. Calls to the Windows API gives you access to routines that do things like drawing menu bars, manipulating bitmaps, playing sound files, and pretty much every other function of Windows.



How do I call a DLL?

Basically, you declare a DLL procedure which you can call in your VB program which in turn passes data to and/or retrieves data from the DLL.



Why can't I use an index with my VB accessed database?

There is a mistake in the 3.0 docs which says you can set the active index for a recordset. You can't. The data control uses the primary key for tables and physical order (I think) for dynasets.


 
Can I distribute my app without vbrunXXX.dll?

If you are sure that your users have it or can get it, you can easily distribute your app without vbrunXXX.dll. Simply remove the file from your distribution disk or zip file and and ALSO remove it from the setup.lst file.



Does VBA support VBXs?

No. VBX is a dead end. There will never be 32-bit VBXs, but OCXs using OLE 2. VBA is more a subset of VB 4 than VB 3, but it does not fully support OCX yet. It will, though.



Can I create CGI scripts in VB?

Yes. What you need is simply a program (any program, even a DOS or NT batch file) that can pass and read command-line parameters, and read and write standard input. The latter is not supported directly in VB code, but you can easily access the API functions from VB.



How do you register a component?

Compiling the component, running REGSVR32 MyDLL.dll 



What are the different ways to Declare and Instantiate an object in Visual Basic 6?

Dim obj as OBJ.CLASS with eitherSet obj = New OBJ.CLASS orSet obj = CreateObject(OBJ.CLASS?) orSet obj = GetObject( , OBJ.CLASS?)orDim obj as New OBJ.CLASS 



Describe Database Connection pooling (relative to MTS )?

This allows MTS to reuse database connections. Database connections are put to sleep as opposed to being created and destroyed and are activated upon request. 



 
TekTipsDownload
GateExam
Academic Projects
TekTipsExperts
Android