Vb.Net: CheckedListBox - Get The Value From A Certain Line

Vb.Net: CheckedListBox - Get The Value From A Certain Line

isocam
Collaborator Collaborator
439 Views
3 Replies
Message 1 of 4

Vb.Net: CheckedListBox - Get The Value From A Certain Line

isocam
Collaborator
Collaborator

Can anybody help?

 

I have a CheckedListBox in a Vb.Net application that I am using with Inventor.

 

I need to get the value from a certain line in the CheckedListBox and, for testing purposes, display it in a message box.

 

For example, say I have a CheckListBox containing 5-lines of text thus....

 

BLACK

WHITE

GREEN 

YELLOW

RED

 

How do I get the value of line 3, for example (in this case it would be GREEN)?

 

I am using the code:

 

Msgbox(CheckedListBox1.GetItemText(3))

 

But it is giving me a number and not the text "GREEN"

 

Many thanks in advance!

 

Darren

0 Likes
440 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

Have you already tried just CheckedListBox1.Items.Item(3)?  I do not recall if that collection maintains the original order or not though.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

FINET_Laurent
Advisor
Advisor

Hi @isocam,

 

Not too sure about the .getItemText method. I would use this instead :

Public Class Form1
    Private Sub Button1_Click() Handles Button1.Click
        MsgBox(CheckedListBox1.Items(0).ToString())

    End Sub
End Class

 

FINET_Laurent_0-1704800592797.png

Does this suits your needs?

 

Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 4 of 4

FINET_Laurent
Advisor
Advisor

@isocamn,

 

Also note the starting index of the collection is 0.

 

Kind regards,

FINETL.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes