How to convert code snipped from VB6 to Visual Studio 2005/VB (VB7?)

  • Thread starter Thread starter vb newbie
  • Start date Start date
V

vb newbie

I found some sample VB code which I'm trying to implement in Visual
Studio 2005. I think the code was VB6. VS05 doesn't like the syntax.
I've distilled things down to the part with the error:

Public Sub WontRun(ByVal v As ListView)
Dim x As ListItem
x = v.ListItems.Add(, , "c:\test\file.txt")
End Sub


Error 1 'ListItems' is not a member of
'System.Windows.Forms.ListView'.


Does anybody know what the correct code would be for this under Visual
Studio 2005/VB?
 
I made a subset of the actual code. This is part of a subroutine which
adds filepath/filename data to a ListView...
 
Assuming "v" is a listview control:

Dim x as ListViewItem
x = v.Items.Add(, , "c:\test\file.text")

Thanks,

Seth Rowe
 
I found some sample VB code which I'm trying to implement in Visual
Studio 2005. I think the code was VB6. VS05 doesn't like the syntax.
I've distilled things down to the part with the error:

Public Sub WontRun(ByVal v As ListView)
Dim x As ListItem
x = v.ListItems.Add(, , "c:\test\file.txt")
End Sub


Error 1 'ListItems' is not a member of
'System.Windows.Forms.ListView'.


Does anybody know what the correct code would be for this under Visual
Studio 2005/VB?

The syntax for ListView in VS05 is somewhat different than in VB6.

This is a very elementry question. The answer can easily be found in the Help file,
with simple example. Lookup ListView Control, adding list iems, and, adding
ListSubItems.

Gene
 
Have you tried the VB 6 converter in VS 2005? It handles short code
segments really well. Just don't use it for entire projects as it will make
a mess of the converted code.

Mike Ober.
 
Back
Top