Reference form from one project in another?

T

Thief_

I have two projects in one solution:

a.. Outlook Monitor
b.. Tray Notification
Both contain a form called "Form1.vb". How do I reference "Outlook
Monitor"'s Form1 from "Tray Notification"'s form1? Here's my code example
taken from "Tray Notification"'s form1:

Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'--- Create ContextMenu
'Dim TrayContextMenu As ContextMenu = New ContextMenu

'Add itens on ContextMenu
TrayContextMenu.MenuItems.Add("&Restore", New
System.EventHandler(AddressOf Me.mnuRestore_click))
TrayContextMenu.MenuItems.Add("-")
TrayContextMenu.MenuItems.Add("&Exit", New
System.EventHandler(AddressOf Me.mnuExit_click))

'--- Create NotifyIcon
'Dim TrayNotifyIcon As BalloonTip = New BalloonTip

' Show Notify Icon
TrayNotifyIcon.Text = Me.Text ' Help text for MouseLeave on Icon
TrayNotifyIcon.Icon = Me.Icon ' Icon for NotifyIcon
TrayNotifyIcon.Form = Me ' Form to restore when DoubleClick on Icon
TrayNotifyIcon.ContextMenu = TrayContextMenu ' ContextMenu for
RightClick on Icon
TrayNotifyIcon.Visible = True ' Show icon in TaskBar

' Show Balloon Tip
TrayNotifyIcon.ShowBalloon(Me.Text, "Line 1" + vbLf + "Line 2",
BalloonTip.NotifyInfoFlags.Info, 1000)
End Sub


I want to change the three lines of code under the line "' Show Notify Icon"
to reference the other project's form.
 
G

Guest

Use an imports statement then a qualifier for form1, i.e., in your
Traynotification project module where you want to call Outlook Monitor's
Form1,

Imports OutlookMonitor (or whatever the project is labeled in the solution
explorer)


Then to show the form;

OutlookMonitor.Form1.Show

I think this is what you need. Good Luck
 

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