get the property of an obj throug listbox item

Discussion in 'AutoCAD' started by youngman, Aug 26, 2004.

  1. youngman

    youngman Guest

    hi,

    i made a listbox to show all the properties(with values) of a selected
    object on sreen.

    whenever i click a item of the list box , i want to get the property which
    the selected listitem represents

    is there a simple way to fulfill this .

    thank you.
     
    youngman, Aug 26, 2004
    #1
  2. Private Sub UserForm_Initialize()
    ListBox1.AddItem "1"
    ListBox1.AddItem "2"
    End Sub

    Private Sub ListBox1_Click()
    MsgBox ListBox1.Value
    End Sub

    Regards - Nathan
     
    Nathan Taylor, Aug 26, 2004
    #2
  3. youngman

    youngman Guest

    Thanks for your advice.
    i want to get the property which
    the selected listitem represents,instead of the listvalue.

    for example,

    there length,angle,etc in a listbox,after i select a line,
    next,when i cilck length, i want to get the line.length (a value)

    thank you .

    best regard
     
    youngman, Aug 26, 2004
    #3
  4. If you would like to post your DVB zipped up I will have a look at it tommorrow. I think I understand what you are trying to achieve now.
    Regards - Nathan
     
    Nathan Taylor, Aug 26, 2004
    #4
  5. youngman

    youngman Guest

    Thanks for your advice.
    here are my codes.

    Dim AimObj As AcadObject
    Dim SelectedProperty As String
    Dim SelectedPropertyValue As Double
    Dim SelectedPointProperty As Variant
    Dim NmofAimObj As String

    Private Sub CommandButton1_Click()
    Me.hide
    Dim basePnt As Variant
    On Error Resume Next
    ListboxClear
    ThisDrawing.Utility.GetEntity AimObj, basePnt, "Select an object"
    If Err <> 0 Then
    Err.Clear
    MsgBox "Good Bye.", , ""
    Exit Sub
    Else
    'MsgBox "The object type is: " & AimObj.entityName, , "GetEntity
    Example"
    Label1.Caption = TypeName(AimObj) '
    ddd
    End If
    Me.Show
    End Sub
    Sub ddd()
    NmofAimObj = AimObj.ObjectName
    Debug.Print " NmofAimObj = "; NmofAimObj

    If StrComp(NmofAimObj, "AcDbArc") = 0 Then
    ListBox1.AddItem "ArcLength "
    ListBox1.AddItem "Area "
    ListBox1.AddItem "CenterX"
    ListBox1.AddItem "CenterY"
    ListBox1.AddItem "CenterZ"
    ListBox1.AddItem "EndAngle "
    ListBox1.AddItem "EndPointX"
    ListBox1.AddItem "EndPointY"
    ListBox1.AddItem "EndPointZ"
    ListBox1.AddItem "Radius "
    ListBox1.AddItem "StartAngle "
    ListBox1.AddItem "StartPointX"
    ListBox1.AddItem "StartPointY"
    ListBox1.AddItem "StartPointZ"
    ListBox1.AddItem "TotalAngle"

    etc*****

    End If
    End Sub

    Private Sub ListBox1_Click()
    SelectedProperty = ListBox1.Value
    GetPropertyValue
    End Sub

    Private Sub ListboxClear()
    ListBox1.Clear
    End Sub 'OK

    Private Sub GetPropertyValue()
    If StrComp(NmofAimObj, "AcDbArc") = 0 Then
    If StrComp(SelectedProperty, "ArcLength") = 0 Then
    SelectedPropertyValue = AimObj.ArcLength
    ElseIf StrComp(SelectedProperty, "Area") = 0 Then
    SelectedPropertyValue = AimObj.Area
    ect****
    End If
    End If
    TextBox1.Text = SelectedPropertyValue
    End Sub

    thanks.

    best regards
     
    youngman, Aug 26, 2004
    #5
  6. The problem lies in the ListBox1.AddItem statements where some of them have a space at the end of the string.
    Regards - Nathan
     
    Nathan Taylor, Aug 27, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.