AnsweredAssumed Answered

Accessing Sub in Module from Form

Question asked by James Gannatal on Sep 16, 2011
Latest reply on Sep 16, 2011 by Bnaya Livne

I am trying to access a sub in a module from a user form in VB.Net. I know how to do this in VB but not sure what the difference is.




Imports SolidWorks.Interop.sldworks

Imports SolidWorks.Interop.swconst

Imports System


Public Class SolidWorksMacro


    Public Sub main()


        Dim Form1 As New Form1



    End Sub


    Public Sub BigBlock()

        Dim swDoc As ModelDoc2 = Nothing

        Dim swPart As PartDoc = Nothing

        Dim swDrawing As DrawingDoc = Nothing

        Dim swAssembly As AssemblyDoc = Nothing

        Dim boolstatus As Boolean = False

        Dim longstatus As Integer = 0

        Dim longwarnings As Integer = 0


        swDoc = CType(swApp.OpenDoc6("H:\Home\Block.SLDPRT", 1, 0, "", longstatus, longwarnings), ModelDoc2)

        swApp.ActivateDoc2("Block.SLDPRT", False, longstatus)

        swDoc = swApp.ActiveDoc

    End Sub


    Public swApp As SldWorks



End Class

UserFrom Code:


Public Class Form1


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


    BigBlock 'Not sure what to add here to access the sub. 


    End Sub


End Class


I tried a few different variations to access the subroutine in the module but not sure why I can not access it. Any help would be greatly appreciated.