I'm trying to load a form when checkout a file from vault.
And I tested with sample code as shown as below.
Imports EdmLib Public Class Class1 Implements IEdmAddIn5 Public name As String Public Sub GetAddInInfo(ByRef poInfo As EdmAddInInfo, poVault As IEdmVault5, poCmdMgr As IEdmCmdMgr5) Implements IEdmAddIn5.GetAddInInfo 'Specify add-in information poInfo.mbsAddInName = "My first add-in" poInfo.mbsCompany = "The name of my company" poInfo.mbsDescription = "This is a very nice add-in." poInfo.mlAddInVersion = 1 'Specify minimum version of SOLIDWORKS Enterprise PDM poInfo.mlRequiredVersionMajor = 5 poInfo.mlRequiredVersionMinor = 2 'Notify when a file has been added poCmdMgr.AddHook(EdmCmdType.EdmCmd_PostAdd) 'Notify when a file has been checked out poCmdMgr.AddHook(EdmCmdType.EdmCmd_PostLock) 'Notify when a file is about to be checked in poCmdMgr.AddHook(EdmCmdType.EdmCmd_PreUnlock) 'Notify when a file has been checked in poCmdMgr.AddHook(EdmCmdType.EdmCmd_PostUnlock) End Sub Public Sub OnCmd(ByRef poCmd As EdmCmd, ByRef ppoData As Array) Implements IEdmAddIn5.OnCmd 'Check the type of hook that triggered this call Select Case poCmd.meCmdType Case EdmCmdType.EdmCmd_PostAdd name = "PostAdd" Case EdmCmdType.EdmCmd_PostLock name = "PostLock" 'Initiate the Form Here Dim myform As New Form1 myform.ShowDialog() Case EdmCmdType.EdmCmd_PreUnlock name = "PreUnlock" Case EdmCmdType.EdmCmd_PostUnlock name = "PostUnlock" Case Else name = "?" End Select 'Check the upper and lower bounds of the array Dim message As String message = "" Dim index As Long index = LBound(ppoData) Dim last As Long last = UBound(ppoData) 'Append the paths of all files to a string While index <= last message = message + ppoData(index).mbsStrData1 + vbLf index = index + 1 End While 'Display a message to the user 'message = "The following files were affected by a " + name + " hook:" + vbLf + message Dim vault As EdmVault5 vault = poCmd.mpoVault vault.MsgBox(poCmd.mlParentWnd, message) End Sub End Class
And I want to load the below form to get output value. In the text box I want to show up the results ("name").
Form Codes :
Public Class Form1 Dim callClass As New Class1 Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Me.Close() End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click TextBox1.Text = callClass.name End Sub End Class
its loading a form successfully. But once I click the button "Get Value" Nothing I get.
Could you please anyone help with this issue?.
Thanks a lot