开发者

VB ListBox.Items throwing compile error

开发者 https://www.devze.com 2023-02-27 04:35 出处:网络
I am trying to read all selected items from a listbox in Visual Basic. Dim x As Integer Dim testValue As String

I am trying to read all selected items from a listbox in Visual Basic.

Dim x As Integer
Dim testValue As String
testValue = "20"

For x = 0 To Me.ListBox1.Items.Count() - 1
      If Me.ListBox1.Items.Item(x) = testValue The开发者_运维知识库n
            MessageBox.Show ("Found it")
            Exit Sub
      End If
Next x

is the code I am trying. But When I run the code, I am getting "Compile error : Method or data member not found"

I guess I am missing some references to use "ListBox.Items" method right? What is the required references/library.

Thanks!!!


I copied and pasted your code into a new project. Added a form with a ListBox. Ran the code and it worked perfectly.

Are you sure the problem is in this part of the project?

0

精彩评论

暂无评论...
验证码 换一张
取 消