VB/DOS Bugs/Fixes 1/

 BBS: Inland Empire Archive
Date: 10-26-92 (10:26)             Number: 342
From: MICHAEL MALLEY               Refer#: NONE
  To: ALL                           Recvd: NO  
Subj: VB/DOS Bugs/Fixes     1/       Conf: (2) Quik_Bas
Hello everyone!

I have been using VB/DOS extensively for quite some time now, and have
run into numerous bugs, that unless you are looking for them, you
might never notice them.  The following bug list is my own, and is not
all inclusive.  That is to say, the following bugs and work arounds are
not part of Microsoft's data base, and there may be more bugs that MS
has announced, however I have seen no such list.  Please feel free to
forward this message to other nets and echoes as appropriate.

If anybody needs some rudimentary code to help them out with the
MSGBOX problem in numbers 5 and 6, just ask, and I will be more than
happy to post it.

1.  In the "T" index of the on-line help, there is a hyper-link
    entitled:  "Text Telephone (TT)".   This is not a valid link.
    Selecting this topic does nothing.

2.  Clicking on the border of the drop down combo box causes a click
    event.

    Explanation:

    If the ListIndex property of a combo box has a value of -1 (no item
    from the list is selected), when the combo box is dropped down, no
    item in the list will be highlighted.  If the user clicks on the
    border, the list is closed correctly, however a click event is
    initiated, and any code in the click event that depends on ListIndex
    will fail.  If the user presses and holds the mouse button, the
    closest item in the list will be selected prior to closure.

    Solution:

    Include the following line of code at the beginning of the click
    event for the combo box:

       IF Combo1.ListIndex = -1 THEN EXIT SUB

3.  Setting SelStart or the Text property of a combo box will cause a
    subsequent click event to set ListIndex to -1.

    Explanation:

    The user interface in VB does not left justify text in text boxes
    when the user changes focus.  This results in data being difficult
    to read.  The solution to this problem seems pretty straight
    forward, in the lost focus event for objects with a text property,
    set the SelStart property to 0, or reassign the text property to
    itself (Object.Text = Object.Text).  This should left justify the
    text.  If you do this to a combo box however, the subsequent
    selection from the list for that combo box will result in a
    ListIndex value of -1. This will cause any code in the click event
    that relys on the ListIndex value to fail.

    Please note that this only occurs if the user selects an item from
    the list other than what was previously selected.  If item #1 is
    selected from the list, the bug will not make itself known until the
    user selects an item other than #1.  Reselecting item #1 does not
    initiate the bug.

    Solution:

    To left justify the text without enabling the bug, use the following
    code:

      Temp$ = Combo1.Text
      Combo1.Text = ""
      Combo1.Text = Temp$

    If you are using a central LostFocus event handler for all objects
    with Text properties to perform data and length verification, and
    you are passing the object to that procedure you will need to
    include the following structure:

      IF TYPEOF Object IS ComboBox Then
         '--- Above code
      ELSE
         Object.SelStart = 0
      END IF

4.  Objects that fall under a combo box's drop down list are not updated
    when the list is closed.

    Explanation:

    When the drop down list of a combo box is shown, the background is
    saved in an internal buffer.  When the list is hidden, that buffer
    is restored to the screen.  If the list covers something that gets
    updated according to a selected item in the list, when the list is
    hidden, the area of the screen that the list occupied will retain
    its prior state.

    I realize that this may be a little hard to comprehend, so I'll put
    it another way.  Let's assume that we have a combo box and a list
    on the screen:

       [ Combo1       ] v
    +--------------------------+
    | List1                    |
    |                          |
    |                          |
    +--------------------------+

    The drop down list of the combo box contains the entries "Numbers"
    and "Letters".  When the user selects "Numbers" or "Letters", a
    click event occurs.  If Combo1.ListIndex = 0 then List1 is updated
    to display the entries "12345", "678910",  and "11 12 13 14 15".
    If Combo1.ListIndex = 1 then the entries are "AaBbCcDd", "EeFfGgHh",
    and "IiJjKkLl".  Assuming that List1 currently shows the numbers,
    when "Letters" is selected from the drop down list in Combo1,
    the list is closed, and List1 will look like this:

    +--------------------------+
    | A2345                    |
    | E78919                   |
    | I1 12 13 14 15           |
    +--------------------------+

    The list will repaint itself when it recieves focus, but this looks
    highly unprofessional.

    Please note that this problem only occurs when the item is selected
    using the keyboard.  If the user used a mouse, then the list is
    first hidden, then the click event is initiated.  Therefore when the
    list is updated, nothing rests on top of it.

    Solution:

    The secret is well placed REFRESH methods.  You will need to include
    the following code for the combo box:

    SUB Combo1_KeyUp (KeyCode AS INTEGER, Shift AS INTEGER)
      SELECT CASE KeyCode
        CASE 115          '-- <F4>
          List1.REFRESH
        CASE 38, 40       '-- <Up> <Down>
          '-- Check for <Alt> key
          IF Shift AND 4 THEN List1.REFRESH
      END SELECT
    END SUB

    SUB Combo1_LostFocus()
      List1.REFRESH
    END SUB
>>> Continued to next message

 * SLMR 2.1a * Help me!  Someone turned reality back on.

--- Maximus 2.00
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET