Shorten rules with Sub

Shorten rules with Sub

alikhan.ganayev
Enthusiast Enthusiast
280 Views
1 Reply
Message 1 of 2

Shorten rules with Sub

alikhan.ganayev
Enthusiast
Enthusiast

So what I would like to do is shorten a couple of my rules by using subs but I haven't used them before. I tried looking online for the solution but somehow I keep getting it wrong and I don't know why. It is my understanding that I'd need to use Sub Main() and End Sub, then call this sub whenever necessary. Can there only be one sub main? This sub would need to be called within an If Then statement. How would I name this sub, as I assume this is necessary. Inventor seems to keep telling me that I'm using it wrong so I thought I'd ask around here.  Inventor 2022 / Windows 10.

0 Likes
281 Views
1 Reply
Reply (1)
Message 2 of 2

A.Acheson
Mentor
Mentor

Sub Main() and End Sub, to be only used for the start and finish of a vb.net sub routine which you use in the the ilogic editor. 

 

All other sub routines between the main routine use Sub() and End Sub which is similar to VBA. 
You can source info on how to use these by using vb.net resources or VBA resources. VBA has subtle differences but many resources are similar. So tutorials on vba would be also beneficial as there is lots of video content available. 

https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/procedures/...


Using in the ilogic editor

https://knowledge.autodesk.com/support/inventor-products/learn-explore/caas/CloudHelp/cloudhelp/2014...

 

Here is an example

  • Call is an optional word. I like to keep it there to quickly identify the sub routine call. 


  • “file update“ is the optional argument passed through to the sub routine from the call line. 

 

 

 
Sub Main()

Call tellOperator("file update") 

End Sub

Sub tellOperator(ByVal task As String)
    Dim stamp As Date
    stamp = TimeOfDay()
    MsgBox("Starting " & task & " at " & CStr(stamp))
End Sub

 

 

 

Here is a little more complicated example copy and paste the contents of the text file or use the text file directly as an external rule. 

https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/how-do-get-action-dialogue-box-in-ilogi...

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes