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.

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.

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.

Line Continuation

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
URL: http:// cpcug.org / user / clemenzi / technical / Languages / VB_3_0_To_6_0.htm