Listbox with layernames VB

Valued Contributor
Valued Contributor

 

Hello all

I have a checked listbox ( Layerlijst) with the layernames of my draftfile and i want to show only the checked layers.

I use this code to walk trough the list for show or hide my layers:

' Only show selected layers

For m = 1 To objLayers.Count

   objLayer = objLayers.Item(m)

   If Layerlijst.GetItemCheckState(m) Then

      objLayer.Show = True

   Else

      objLayer.Show = False

   End If

Next

When it reaches the last item of the listbox i get an error message on Layerlijst.GetItemCheckState(m)

It says:

Invalid argument: Value of 13 is not valid for index.

Parametername: index

Can anyone tell me what i do wrong?

Thanks

Patrick

 

Posted by: Patrick Keller
Post date: 3/20/2009 2:47:00 AM

2 REPLIES

RE: Listbox with layernames VB

Valued Contributor
Valued Contributor

Assuming that you're using VB.NET, arrays are zero based. COM API's are one based. VB 6 was one based.

 

Posted by: Jason Newell
Post date: 3/20/2009 7:17:56 AM

RE: Listbox with layernames VB

Valued Contributor
Valued Contributor

 

I understand what u mean Jason and i found out what i did wrong.

After filling my listbox i created a temp layer so my actual layer count was 1 higher then my listbox.

Thanks

Patrick

 

Posted by: Patrick Keller
Post date: 3/20/2009 9:37:52 AM