Reduce Items in ComboBox
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Reduce Items in ComboBox

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
payam_dl
Guest





Posted: Thu Jan 13, 2005 7:06 pm    Post subject: Reduce Items in ComboBox Reply with quote

In a Combo I have for example 10 Items. 4 of this 10 Items are repeated Items. How could I reduce or remove this repeated Items automatically ? is there any Solution?
Thank you in advance

Back to top
Warren M
Guest





Posted: Thu Jan 13, 2005 7:17 pm    Post subject: Re: Reduce Items in ComboBox Reply with quote

Hello payam_dl.

How is the combobox being populated?

Without knowing any details...
If you're populating via a loop... setup a temp var to hold the current item, and if the next one is the same, don't add it...

Hope this helps
Warren M
Back to top
payam_dl
Guest





Posted: Thu Jan 13, 2005 8:07 pm    Post subject: Re: Reduce Items in ComboBox Reply with quote

Hi Warren H
I read layer of blocks and add them with addItem to ComboBox via a loop!
for example by first block, layer is 0. second block layer is 1 but third block layer is 0 again !
How could I do this ?
Thank you for your attention.

Back to top
payam_dl
Guest





Posted: Thu Jan 13, 2005 8:30 pm    Post subject: Re: Reduce Items in ComboBox Reply with quote

P.S.
I put here a sample code for better over view!

..
..
For Each elem In ThisDrawing.ModelSpace
With elem
If StrComp(.EntityName, "AcDbBlockReference", 1) _
= 0 Then
If .HasAttributes Then
layerName = elem.Layer

ComboBox1.AddItem layerName, k
k = k + 1
End If
End If
End With
Next elem
Back to top
Tim Arheit
Guest





Posted: Thu Jan 13, 2005 8:48 pm    Post subject: Re: Reduce Items in ComboBox Reply with quote

On Thu, 13 Jan 2005 15:07:24 GMT, payam_dl <nospam@address.withheld>
wrote:

Quote:
Hi Warren H
I read layer of blocks and add them with addItem to ComboBox via a loop!
for example by first block, layer is 0. second block layer is 1 but third block layer is 0 again !
How could I do this ?
Thank you for your attention.

1. Search the combo box each time a layer is added., or

2. build the list in a collection first. ie.

' This won't allow duplicate layers to be added to the
collection
on error resume next
mycollection.add("layer","layer")


then use the collection to populate the combobox.


-Tim
Back to top
Paul Richardson
Guest





Posted: Thu Jan 13, 2005 9:49 pm    Post subject: Re: Reduce Items in ComboBox Reply with quote

Basic Idea..

Private Sub UserForm_Click()
For Each elem In ThisDrawing.ModelSpace
With elem
If StrComp(.EntityName, "AcDbBlockReference", 1) _
= 0 Then
If .HasAttributes Then
layername = elem.Layer

Select Case blnIsListed(layername)
Case False
ComboBox1.AddItem layername
End Select

End If
End If
End With
Next elem
End Sub


Public Function blnIsListed(inLayerName) _
As Boolean
For iJc = 0 To ComboBox1.ListCount - 1
If ComboBox1.List(iJc) = inLayerName Then
blnIsListed = True
Exit For
Else: blnIsListed = False
End If
Next iJc
End Function

gl

Paul


"payam_dl" <nospam@address.withheld> wrote in message
news:30424296.1105630242983.JavaMail.jive@jiveforum1.autodesk.com...
Quote:
P.S.
I put here a sample code for better over view!

.
.
For Each elem In ThisDrawing.ModelSpace
With elem
If StrComp(.EntityName, "AcDbBlockReference", 1) _
= 0 Then
If .HasAttributes Then
layerName = elem.Layer

ComboBox1.AddItem layerName, k
k = k + 1
End If
End If
End With
Next elem
Back to top
payam_dl
Guest





Posted: Fri Jan 14, 2005 10:03 am    Post subject: Re: Reduce Items in ComboBox Reply with quote

Perfect ! Thank you Paul !
Back to top
Paul Richardson
Guest





Posted: Fri Jan 14, 2005 8:21 pm    Post subject: Re: Reduce Items in ComboBox Reply with quote

Your quite welcome...
"payam_dl" <nospam@address.withheld> wrote in message
news:28305964.1105689963684.JavaMail.jive@jiveforum2.autodesk.com...
> Perfect ! Thank you Paul !
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Contact Us
Powered by phpBB