Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am new to this field, while converting a vb project to vb.net i got a error
this is the vb coding

-----------------------------------------------------------------------------------
VB
Private Sub Command4_Click()
    Frame1.Visible = False
'  The mailman object is used for receiving (POP3)
'  and sending (SMTP) email.
Dim mailman As New ChilkatMailMan2

mailman.UnlockComponent "UnlockCode"

mailman.MailHost = txtPopserver.Text '"pop.gmail.com"
mailman.PopUsername = txtpoplogin.Text
mailman.PopPassword = txtpoppass.Text
mailman.PopSsl = 1 ' Use this for gmail
mailman.MailPort = 995 'Use this for gmail


Dim bundle As ChilkatEmailBundle2
'  Copy the all email from the user's POP3 mailbox
'  into a bundle object.  The email remains on the server.
Set bundle = mailman.CopyMail()

If (bundle Is Nothing) Then
    MsgBox mailman.LastErrorText
Exit Sub
End If

Dim i As Long
Dim Str As String
Dim LvItem As ListItem
Dim email As ChilkatEmail2
Form2.ListView1.ListItems.Clear
For i = 0 To bundle.MessageCount - 1
    Set email = bundle.GetEmail(i)
    Set LvItem = Form2.ListView1.ListItems.Add
    LvItem.Text = email.From
    LvItem.SubItems(1) = email.subject
    LvItem.SubItems(2) = i
Next
mailman.Pop3EndSession
Form2.Show
'Unload Me
End Sub
-----------------------------------------------------------------------------------


after converting it to vb.net 

-----------------------------------------------------------------------------------
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        GroupBox3.Visible = False
        '  The mailman object is used for receiving (POP3)
        '  and sending (SMTP) email.
        Dim mailman As New CHILKATMAILLib2.ChilkatMailMan2

        mailman.UnlockComponent("UnlockCode")

        mailman.MailHost = TextBox10.Text '"pop.gmail.com"
        mailman.PopUsername = TextBox12.Text
        mailman.PopPassword = TextBox11.Text
        mailman.PopSsl = 1 ' Use this for gmail
        mailman.MailPort = 995 'Use this for gmail


        Dim bundle As CHILKATMAILLib2.ChilkatEmailBundle2
        '  Copy the all email from the user's POP3 mailbox
        '  into a bundle object.  The email remains on the server.
        bundle = mailman.CopyMail()

        If (bundle Is Nothing) Then
            MsgBox(mailman.LastErrorText)
            Exit Sub
        End If

        Dim i As Integer

        'UPGRADE_NOTE: Str was upgraded to Str_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'

        Dim LvItem As System.Windows.Forms.ListViewItem
        Dim email As CHILKATMAILLib2.ChilkatEmail2
        Form2.ListView1.Items.Clear()
        For i = 0 To bundle.MessageCount - 1
            email = bundle.GetEmail(i)
           

 'UPGRADE_ISSUE: MSComctlLib.ListItems method ListView1.ListItems.Add was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'


            LvItem = Form2.ListView1.Items.Add()
            LvItem.Text = email.From
            

'UPGRADE_WARNING: Lower bound of collection LvItem has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
           

            If LvItem.SubItems.Count > 1 Then
                LvItem.SubItems(1).Text = email.subject
            Else
                LvItem.SubItems.Insert(1, New System.Windows.Forms.ListViewItem.ListViewSubItem(Nothing, email.subject))
            End If
            


'UPGRADE_WARNING: Lower bound of collection LvItem has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
           


           If LvItem.SubItems.Count > 2 Then
                LvItem.SubItems(2).Text = CStr(i)
            Else
                LvItem.SubItems.Insert(2, New System.Windows.Forms.ListViewItem.ListViewSubItem(Nothing, CStr(i)))
            End If
        Next
        mailman.Pop3EndSession()
        Form2.Show()

    End Sub
--------------
---------------------------------------------------------------------
I got error at this point
LvItem = Form2.ListView1.Items.Add()
AND THE ERROR IS
Error 1 Overload resolution failed because no accessible 'Add' accepts this number of arguments
Posted
Updated 21-May-12 23:35pm
v3

1 solution

In .Net, you need to pass an argument to the Add method. This argument is the item that is added to the ListView.
Here[^] is an example.
 
Share this answer
 
Comments
Member 8948677 23-May-12 8:20am    
thanx

when i passed ListView it gives an error--Error 1 'ListView' is a type and cannot be used as an expression.

i passed LvItem it is accepted but with a warning of null reference exception.


also one error i am getting while converting vb6 to vb.net
vb.net code is--------
'UPGRADE_WARNING: Couldn't resolve default property of object WebBrowser1.Document.Body. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
WebBrowser1.Document.DomDocument.Body.innerHTML = email.Body
Status.Text = "Completed"
-----------------------------------------------------------------------
vb code is
WebBrowser1.Document.Body.innerHTML = email.Body
Status.Caption = "Completed"
--------

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900