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

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?
 
V

vb newbie

I made a subset of the actual code. This is part of a subroutine which
adds filepath/filename data to a ListView...
 
R

rowe_newsgroups

Assuming "v" is a listview control:

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

Thanks,

Seth Rowe
 
G

gene kelley

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
 
M

Michael D. Ober

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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top