• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 494
  • Last Modified:

Code created with Visual Basic not working on Vb.net

When I use these two bits of code that were created in Visual basic 2010, they work fine. When I try to create the same thing in Visual studio VB.net, most of it is unrecognized.

I'm Imported Visual basic and forms, but it seems that some parts do not work.

What am I missing, or can the code even be used between the two.

thanks
'End If
        Dim file As String = folder.ToString
        If ListView1.SelectedItems.Count > 0 Then
            Dim lv1 As ListViewItem = ListView1.SelectedItems(0)
            Dim filename As String = file & "\" & lv1.Text

            Dim msg As MapiMessage = MapiMessage.FromFile(filename)
            txtFrom.Text = msg.SenderName
            txtSenderAddress.Text = msg.SenderEmailAddress
            txtSubject.Text = msg.Subject
            txtCC.Text = msg.DisplayCc
            txtBody.Text = msg.Body
        End If
    End Sub

    Private Sub btnOutlook_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOutlook.Click
        Dim folder As String = CStr(TreeView1.SelectedNode.Tag)
        Dim file As String = folder.ToString
        If ListView1.SelectedItems.Count > 0 Then
            Dim lvO As ListViewItem = ListView1.SelectedItems(0)
            Dim filename As String = file & "\" & lvO.Text
            Dim msg As MapiMessage = MapiMessage.FromFile(filename)
            Process.Start(Path.Combine("outlook.exe", filename))
        End If
    End Sub

Open in new window

0
General_GSpot
Asked:
General_GSpot
  • 8
  • 8
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
which part is not recognized? what is the other version of VB.net you are trying to copy your code to? have you added a reference to MapiMessage (check your VS2010 project to see what DLL it is)?
0
 
General_GSpotAuthor Commented:
Well, in Vb.net 2008, under listview, it doesn't recognize 'selecteditems' just items. Also, the process.start(combine.path()) doesn't work, where Visual Basic it works fine.

Mapimessage does work, as both can use and recognize the Aspose network DLL. I am able to programatically load one message into text boxes, but I can't get the listview to work properly,so I can't scroll through messages.

OK, so I used Visual Basic Express 2010 to make the original content that works fine, but then i wanted to use the same thing with Visual Studio 2008 to combine all of my little programs into one big one, to be used on our intranet.

I am pretty novice, third week programming :)  Any help would be greatly appreciated.
0
 
Éric MoreauSenior .Net ConsultantCommented:
for Path, add "Imports System.IO" at the top of your form.
0
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

 
General_GSpotAuthor Commented:
I already have it there. That's what's bugging me.
0
 
Éric MoreauSenior .Net ConsultantCommented:
SelectedItems should be recognized. Are you sure ListView1 exist and is a listview control?
0
 
Éric MoreauSenior .Net ConsultantCommented:
this line is not valid (surely not work in VS2010):

Process.Start(Path.Combine("outlook.exe", filename))

Should be only:
Process.Start("outlook.exe", filename)
0
 
General_GSpotAuthor Commented:
OK, here is the one problem i'm having that I remember. Under the components, I have a listview for UI.webcontrols, and one for windows forms. If I uncheck the UI.Webcontrols, I can't see a listview at all. How do I tell the system to use the listview for Forms?

I thjink that is the proble, correct?
0
 
Éric MoreauSenior .Net ConsultantCommented:
is your VS2010 a Windows or web project? it really looks like a Windows project. All the methods are not available for web controls.

also are you aware that Process.Start will start the process (outlook) on your server?
0
 
General_GSpotAuthor Commented:
No the VS is a web project.

I did not know this. How can I start outlook locally and open that file. Is that even possible with a web project? On teh visual basic program, it opens outlook locally, it has to, outlook isn't even on the server.
0
 
Éric MoreauSenior .Net ConsultantCommented:
>>Is that even possible with a web project?

probably but you will have to use javascript (and I cannot help you on this)
0
 
General_GSpotAuthor Commented:
OK, thanks, I will check into this.
0
 
General_GSpotAuthor Commented:
Pointed me in right direction, but still need a bit more help.
0
 
General_GSpotAuthor Commented:
I know I closed this, but here is my code transferred over to VS, thanks to you, I got the listview working but....

Imports System.IO
Imports Aspose.Network.Outlook
Imports mscomctl

Partial Class EmailFinder
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim listview1 As Windows.Forms.ListView
        Dim treeview1 As Windows.Forms.TreeView
        Dim treenode As Windows.Forms.TreeNode
        Dim FolderPath As String = "c:\jobs\emails"
        Dim view As Windows.Forms.ListViewItem
        Dim Tnode As Windows.Forms.TreeNode = treeview1.Nodes.Add("(Drive c:)")
        'AddAllFolders(Tnode, "c:\jobs\emails")
        AddAllFolders(Tnode, FolderPath)

        listview1.View = Windows.Forms.View.Details
        listview1.Columns.Add("filename", 150, Windows.Forms.HorizontalAlignment.Left)
        listview1.Columns.Add("Date", 150, Windows.Forms.HorizontalAlignment.Left)
    End Sub
    Private Sub AddAllFolders(ByVal Tnode As TreeNode, ByVal FolderPath As String)

        Try
            For Each FolderNode As String In Directory.GetDirectories(FolderPath)
                Dim SubFolderNode As TreeNode = Tnode.Nodes.Add(FolderNode.Substring(FolderNode.LastIndexOf("\"c) + 1))

                SubFolderNode.Tag = FolderNode

                SubFolderNode.Nodes.Add("Loading...")
            Next
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub
End Class

Open in new window


Now, it doesn't recognize the Nodes, actually it tells me it can't be a UI.Web.control, but as you can see, I dim'd it a form. What am I doing wrong here. (BTW, this will load the msg files, and then I'll use the process.start)

thanks.
0
 
Éric MoreauSenior .Net ConsultantCommented:
I can't help you much since you are now in a web project. also a web project should never have references to Windows Forms controls (windows.forms.view.details, Windows.Forms.HorizontalAlignment, Windows.Forms.TreeNode, Windows.Forms.ListView, ...)
0
 
General_GSpotAuthor Commented:
OK, thanks.
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

  • 8
  • 8
Tackle projects and never again get stuck behind a technical roadblock.
Join Now