Click here to Skip to main content
11,500,576 members (71,039 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
i am new to this field, while converting a vb project to vb.net i got a error
this is the vb coding

-----------------------------------------------------------------------------------
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 21-May-12 23:22pm
Edited 21-May-12 23:35pm
Abhinav S397.6K
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Member 8948677 at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 305
1 DamithSL 275
2 Maciej Los 260
3 Peter Leow 200
4 Sascha Lefèvre 110
0 Sergey Alexandrovich Kryukov 345
1 Maciej Los 290
2 DamithSL 220
3 Peter Leow 181
4 OriginalGriff 167


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 22 May 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100