VB AddItem Method Gives "Illegal Function Call" for List Box

ID Number: Q75642

1.00

WINDOWS

buglist1.00

Summary:

Below is an example of a problem adding an item to the list box

object in a Visual Basic program.

Microsoft has confirmed this to be a problem with Microsoft Visual

Basic programming system version 1.0 for Windows. We are researching

this problem and will post new information here as it becomes

available.

More Information:

Steps to Reproduce Problem

--------------------------

1. Start Visual Basic with a New Project.

2. Add a list box and a command button on Form1.

3. Add the following code in the Command1_Click event procedure:

Sub Command1_Click ()

a$ = "hello"

list1.AddItem a$, 1

End Sub

4. Run the program by pressing the F5 key. The error message "Illegal

function call" should be displayed. Press the F1 key for additional

help on this error. Help will explain about an improper or

out-of-range argument on the function.

The actual problem concerns the index% of the AddItem method discussed

on page 21 of the "Microsoft Visual Basic: Language Reference" for

version 1.0.

Workaround

----------

The following are two different ways to resolve the problem:

- Leave out the index% option on the AddItem method as shown below.

Sub Command1_Click ()

a$ = "hello"

list1.AddItem a$

End Sub

- Start out with the index% option as 0 instead of 1 as shown below.

Sub Command1_Click ()

a$ = "hello"

list1.AddItem a$, 0

End Sub

The addition of Option Base 1 to the General section of the Form's

code window does not make the above problem go away.

Additional reference words: 1.00