Search code examples
vbacomuserformsolidworks

VBA How To Set Form In Function


I add Form1.vb in my project but ı couldn't show it. Form1.show or Form1.ShowDialog didn't worked beacuse it type is class. Here is the error message;

bc30109 'form1' is a class type and cannot be used as an expression

Solution must be some think like that.

Private Sub Form1Func()
    Dim f1 As Object
    f1 = Form1
    f1.ShowDialog
End Sub
Private Sub OnButtonClick(cmd As Commands_e)
    Select Case cmd
        Case Commands_e.Export_As_SheetMetal
            Form1Func()
        Case Commands_e.AboutUs
            Application.ShowMessageBox("AboutUS")
    End Select
End Sub

Solution

  • Private Sub Form1Func()
        Dim f1 As New Form1
        f1.Show()
    End Sub