VBNotebook Home | Articles | Q&A Session: Common Misconceptions
Here are a few things about VB that cause some confusion, particularly among novices.
__________________________________________________________________________________________
Q1: I need to share a set of functions between several different applications. I have the code in a module in a DLL, but I can't seem to access it. Do I have to put the code in a class and do a lot of OOP stuff to get this to work?
A1: It is perfectly acceptable to create a class that only has a library of functions and whose purpose is solely to expose these functions. You do not necessarily have to conform to OOP methodology when you're working with VB classes. In most cases, you would set the Instancing property of such as class to GlobalMultiUse. This will cause an instance of this class to be created when the DLL is initialized by program and essentially graft your function library onto the existing VB language functions.
__________________________________________________________________________________________
Q2: I was looking at some forms in Notepad today and much to my surprise it said that I was using version 5.0 of VB! I've got VB 6.0 installed on my system. Is something wrong with my installation?
A2: This indicates that VB6 uses the same source file formats as previous versions of VB, at least for the purposes of the internal VB source code parsing engine. VB4 form files had a format ID of VERSION 4.00 and VB3/VB2 files, when saved in ASCII text format, had one of VERSION 2.00. VB1 files could only be stored as binary files and, therefore, did not have an indicator like this. There has only been one version of classes in VB, introduced in VB4, so they are marked as 1.0 for the same reason.
__________________________________________________________________________________________
Q3: In VB6, I am creating an instance of Scripting.Dictionary using CreateObject as stated in the documentation. However, I don't have a clue which DLLs should then be installed on the systems where client my program will be run. Also, do I have to use CreateObject to use the dictionary object?
A3: The file to distribute is the Microsoft Scripting Runtime (SCRRUN.DLL). This file will already be on systems that have Internet Explorer 5 or later installed on them
Also you can add a reference to this file from the
VB References dialog so that you can eliminate the late binding,
CreateObject, method that's presented in the documentation. This
somewhat misleading information was apparently cut and pasted
from the VBScript docs. If you add this reference to your
program, the Packaging and Deployment Wizard will pick up the
file automatically. Once the reference is added, you can work
with it like so...
Dim dicCapitals as Dictionary
Set dicCapitals = New Dictionary
With dicCapitals
.Add "a", "Athens"
.Add "b", "Belgrade"
.Add "c", "Cairo"
End With
__________________________________________________________________________________________
Copyright 2000-2005, J. Frank Carr