Converting Visual Basic 3.0 to 6.0
Trying to convert a working application
from VB 3.0 to VB 6.0 is one of the biggest mistakes
I have made.
Basically, the languages are different.
The converted application runs more than a thousand times slower!
(For real!!)
Loading VB 6.0 requires that you load IE 4.72
which I did not want (but its ok to use).
Some VB 6.0 programs that you write require that
you distribute IE 4.72, otherwise, your
programs won't work.
When importing a project from VB 3.0 to Visual Basic 6.0,
some things are lost.
- ActiveX Controls - The following error message is common
Visual Basic can't upgrade the ActiveX controls
to those provided in
the 'grid32.ocx' library.
Remove this library from the list of available
upgrades?
Yes No Help
I clicked yes, and the following was displayed
'C:\WINDOWS\SYSTEM\grid32.ocx' could not be loaded--Continue
Loading Project?
The same thing happened with anibtn32.ocx, guage32.ocx,
graph32.ocx, keysta32.ocx, msoutl32.ocx, spin32.ocx,
threed32.ocx.
These errors were summarized in *.log.
- Crystal ???? Probably Crystal Reports, probably deleted.
- Common Dialog controls (Open, Save, SaveAs, Print ... -
all implemented via CommDlg.dll)
are all deleted and your custom code becomes worthless.
- The classes SSPanel (ButtonBar_UIPanel3D2) and
SSCommand (Capture_UIButton) were not loaded.
These objects were configured as picture objects instead.
As a result, many of the properties were no longer valid.
- Basically, all VB 3.0 pre-defined symbolic constants
must be replaced with their new VB 6.0 values.
This includes keyboard definitions, colors, common control
options, and everything else you can think of.
Screen.ActiveForm
Screen.ActiveForm no longer works during Form_Load() time.
(I didn't check it else where.)
Now you must use
Set MainForm = Forms(0)
instead of
Set MainForm = Screen.ActiveForm
Automatic Variant Conversion
The automatic conversion of a variant to a string has changed. Using
Dim ErrorCount ' This defines a variant
ErrorCount = 5 ' Assign it a numerical value
Now you must use
object.Text = "There are " & ErrorCount & " differences"
instead of
object.Text = "There are " + ErrorCount + " differences"
Sizing Objects
The routines I used to automatically set the size of the pictureBox
no longer give the correct size.
The following code produces a rectangle
80 characters wide and 25 characters high in VB 3.0 and
79 characters wide and 24.5 characters high in VB 6.0.
MainForm.Compare_Display_UIPicture.FontSize = Size
' Determine the height and width of a typical character
H1 = MainForm.Compare_Display_UIPicture.TextHeight("A")
W1 = MainForm.Compare_Display_UIPicture.TextWidth("A")
MainForm.Compare_Display_UIPicture.Width = 80 * W1
MainForm.Compare_Display_UIPicture.Height = 25 * H1
Re-sizing the form requires knowing information which is not available.
When internal objects are located at 0,0,
you need to know that 0,0 is really 40,300 or what ever.
(This may be my error, the object was not at 0,0 but I thought it was.)
User Interface
When selecting text, when complete rows are selected,
the cursor stops in the middle of the row.
In VB 3.0, it selects entire rows.
Use the Object Browser to determine the methods and properties
of objects.
VB has 34 base classes.
Of these, 20 are UI controls, 7 are defined in Global
(App, Clipboard, Forms, Licenses, Printer, Printers, Screen).
The others are Form, MDIForm, Menu, PropertyPage,
UserControl, UserDocument, VBControlExtender.
DoEvents
DoEvents hangs VB 6.0, works perfect in VB 3.0.
The PushKeys command is available for VB 5.0 and above only.
This is the only reason I moved from VB 3.0 to VB 6.0.
PushKeys works more than 100 times faster than the VB SendKeys command.
However, the keystrokes appear to be queued until a DoEvents command
is executed.
Normally, this would not be a problem except that DoEvents stops
the execution of the VB 6.0 application.
formSave = Screen.ActiveForm.Caption
AppActivate DOSAppName$ ' Transfers control to the DOS application
PushKeys DOS_ScreenCapture$ ' Send keys to the active (DOS) application
' The following 4 lines of code are not needed in VB 3.0,
' These are needed so that the clipboard will be available
For i = 1 To 10 ' I tried various values - 1, 10, 1000 -
' 1 failed, 10 work sometimes, 1000 hung
DoEvents ' Without this - Error - Can't Open Clipboard
Next i
AppActivate formSave ' Without this, DoEvents hangs the application
' The following code never fails in VB 3.0, is intermittent in VB 6.0
tt$ = Clipboard.GetText()
According to
Microsoft,
DoEvents returns control to the Visual Basic program
after the operating system has finished processing the events
in its queue and all keys in the SendKeys queue have been sent.
The Sleep 32-bit API function is a subset of the DoEvents function.
When capturing the DOS screen using sendKeys, it is at least
one thousand times slower than before (VB 3.0 is much faster than VB 6.0).
Even the mouse hangs until to action is complete.
Program Directories
I tried to develop a template in one directory
and do a save as in another directory.
I ended up modifying the wrong data and
lost the template.
There is no way to modify the directory where project members are
saved except to delete and reload them.
I have not yet figured out how to determine where exe's are created.
What a concept -
starting with VB 4.0,
a single command no longer has to be typed on single line.
This is particularly important when defining or calling functions
with lots of parameters.
In order to continue a command on the next line,
terminate the line with a space, underscore, enter.
Both of the following should give the same result
Dim Msg ' Declare variable
Msg = "1st part of string "
Msg = Msg & "Next part of string "
Msg = Msg & "Last part of string"
Msg = "1st part of string " _
& "Next part of string " _
& "Last part of string"
Common Dialog Controls
When converting from VB 3.0 to VB 6.0, the common dialog controls changed.
Author: Robert Clemenzi -
clemenzi@cpcug.org