Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Listview in VB.NET

Status
Not open for further replies.

GlynA

Programmer
May 1, 2002
77
GB
Has anyone come across a problem using the ActiveX Listview control (as supplied with VB6) in VB.NET?

I put this listview on a form and execute the following code:

Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim i As Integer
Dim itmItem As MSComctlLib.ListItem
Dim s As String

For i = 1 To 3
AxListView1.ListItems.Add(CStr(i))
Next

For Each itmItem In AxListView1.ListItems
MsgBox(itmItem.text)
Next

End Sub

The "for each" loop should be executed 3 times, but I find
that it executes 4 times, giving an error on the 4th time
through as itmItem is Nothing.

Is this a known problem?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top