Although there are many ways of coding this I find the easiest is to use the following method:
Public Function DotNetNuke.Entities.Modules.ModuleController.GetModules(ByVal PortalID As Integer) As ArrayList
to obtain an ArrayList of DotNetNuke.Entities.Modules.ModuleInfo objects representing all modules placed on pages of the Portal. I then iterate through the elements of the ArrayList to locate the desired module instance (s). Although the results of GetModules is cached this can be a rather processor intensive iteration in a large portal with many pages each containing many modules and should be done not in the Page_Load handler of Module A but rather in the Settings control for Module A allowing the administrator to select from a a drop-down list or other control which module B (s) will be associated with Module A. The selection (TabID and ModuleID) can then be saved in the ModuleSettings or TabModuleSettings for Module A.
Here's a quick bit of code (untested by similar to that I've used many times before) for you. Note that I have created a helper class ModuleInstance to contain the TabID, TabName, ModuleID, ModuleTitle of the desired modules instances in a form that can easily be bound to a drop-down list presenting the results of the search for the module(s)
Public Class ModuleInstance
Public Property TabID As Integer
Public Property TabName As String
Public Property ModuleTitle As String
Public Property ModuleID As Integer
Public Function Text() As String
Return String.Format("Module {0} on page {1}", ModuleTitle, TabName)
End Function
Public Function Value() As String
Return String.Format("{0}|{1}", ModuleID, TabID)
End Function
End Class
Dim moduleInstances As New List(Of ModuleInstance)
Dim mc As New DotNetNuke.Entities.Modules.ModuleController
Dim portalModules As ArrayList = mc.GetModules(PortalId)
For Each mi As DotNetNuke.Entities.Modules.ModuleInfo In portalModules
If mi.ModuleDefinition.FriendlyName = "MyModuleDefinitionName" Then
Dim myModule As New ModuleInstance()
With myModule
.TabID = mi.TabID
.TabName = mi.ParentTab.TabName
.ModuleTitle = mi.ModuleTitle
.ModuleID = mi.ModuleID
End With
moduleInstances.Add(myModule)
End If
Next
Note that if you are planning to use NavigateUrl or EditUrl to build the link to Module B you will need both the ModuleID and ControlKey (which can be hardcoded) if Module B is to display one of its module controls and not the default view control which will not have a ControlKey.