If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Listbox Error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-08-03, 21:29
vbnovice vbnovice is offline
Registered User
 
Join Date: Dec 2003
Posts: 14
Listbox Error

I'm trying to add an item to a listbox and using the optional Index parameter. I keep getting the following error "Runtime error 5 - Invalid procedure call or argument". My code is simple.

Dim iPlace as Integer
Iplace=2
ListBox(2).Add strOutputs, Iplace

According to the help, setting the Index will put the added item in that position but I keep getting the error.

What am I doing wrong?

TIA
David
Reply With Quote
  #2 (permalink)  
Old 12-09-03, 13:18
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
Try:

listbox.additem stroutputs, iplace
Reply With Quote
  #3 (permalink)  
Old 12-09-03, 14:12
vbnovice vbnovice is offline
Registered User
 
Join Date: Dec 2003
Posts: 14
I should have gone back and corrected that but I was actually doing a
listbox(2).AddItem strOutputs, iPlace

but I believe I found the problem unless someone can tell me different but my listbox(2) was empty when I tried this. I had assumed, it would insert and add the previous indexs but I guess not.

David
Reply With Quote
  #4 (permalink)  
Old 12-09-03, 14:20
sivaroo sivaroo is offline
Registered User
 
Join Date: Nov 2003
Posts: 76
you have to use listbox.newindex to use the index if you are not adding in order. or want to change

listbox.add strOutputs
listbox.ItemData(listbox.NewIndex)=iplace
HTH
Reply With Quote
  #5 (permalink)  
Old 12-10-03, 08:55
pdc_diy_163 pdc_diy_163 is offline
Registered User
 
Join Date: Dec 2003
Location: P.R.C
Posts: 1
Re: Listbox Error

Quote:
Originally posted by vbnovice
I'm trying to add an item to a listbox and using the optional Index parameter. I keep getting the following error "Runtime error 5 - Invalid procedure call or argument". My code is simple.

Dim iPlace as Integer
Iplace=2
ListBox(2).Add strOutputs, Iplace

According to the help, setting the Index will put the added item in that position but I keep getting the error.

What am I doing wrong?

TIA
David
Pass by
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On