Message 1 of 19
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to write a function within Class that can either work on a specified document (if one is supplied) or the current document (if no document is supplied). I can put the exact same function in the rule space and it works perfectly.
However, when I try and use the function within my Class, I get a "Reference to a non-shared member requires an object reference" compile error on the ThisDoc.Document line.
This is how I'm trying to use the class:
Sub Main() MessageBox.Show(TestFun()) MessageBox.Show(TestClass.TestFun(ThisDoc.Document)) 'The following line will not work unless commented-out line within TestClass can be made to work: 'MessageBox.Show(TestClass.TestFun()) End Sub Function TestFun(Optional oDoc As Inventor.Document = Nothing) If oDoc Is Nothing Then oDoc = ThisDoc.Document Return oDoc.DisplayName End Function Class TestClass Shared Function TestFun(Optional oDoc As Inventor.Document = Nothing) 'If oDoc Is Nothing Then oDoc = ThisDoc.Document Return oDoc.DisplayName End Function End Class
Is it possible for ThisDoc.Document to work within a VB Class?
Solved! Go to Solution.