Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

listbox cannot add item

Posted on 1998-04-13
2
Medium Priority
?
332 Views
Last Modified: 2008-02-26
mylistbox give an error 381 whenever i try to add items to the list property in
a subroutine.
eg, private sub Additem()
dim i as integer
for i =0  to 19
listbox.list(i) = array(i)
next
end sub      
can i do the above?
if not , what should i do?
0
Comment
Question by:deuter
2 Comments
 

Accepted Solution

by:
tapsbin earned 200 total points
ID: 1461163
It seems from your question that you have already added items
to your listbox and you want to reassign the elements with the
new values.

(A) If you don't have any element in your listbox then apply
following...

Private Sub AddItem()
    Dim iCnt As Integer
    For iCnt = 0  To 19
    ListBox.AddItem = <Name Of An Array>(iCnt)
Next
End Sub

(B) If you already have the elements and wants to reassign ...

Private Sub AddItem()
    Dim iCnt As Integer

    ListBox.Clear       ' This will clear all the elements
                        ' from your listbox control.
    For iCnt = 0  To 19
    ListBox.AddItem = <Name Of An Array>(iCnt)
Next

If you are not satisfied please tell me more what do you want..
but please do not reopen...i want the points...very eager to
earn the points....

Kind Regards,

TAPS


0
 

Author Comment

by:deuter
ID: 1461164
Taps thanks for your help  it has been very useful.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question