Home All Groups Group Topic Archive Search About

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

Author
4 Oct 2006 12:48 AM
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?

Author
4 Oct 2006 2:56 AM
rowe_newsgroups
Assuming "v" is a listview control:

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

Thanks,

Seth Rowe

vb newbie wrote:
Show quoteHide quote
> 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?
Author
4 Oct 2006 2:56 AM
gene kelley
Show quote Hide quote
On 3 Oct 2006 17:48:59 -0700, "vb newbie" <techquestions.20.technodw***@xoxy.net>
wrote:

>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
Author
4 Oct 2006 4:23 AM
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.

Show quoteHide quote
"vb newbie" <techquestions.20.technodw***@xoxy.net> wrote in message
news:1159922939.038466.259090@m73g2000cwd.googlegroups.com...
> 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?
>