Garren Hahn

VBA Questions

Discussion created by Garren Hahn on May 19, 2020
Latest reply on May 19, 2020 by Mike Dekoning

I'm trying to pick this VBA stuff up, but the terminology is throwing me for a loop. Not really sure what they mean by interfaces. I'm taking it as a way to 'interface' with a Solidworks command? I'm not quite sure. Also, does this have anything to do with methods, members or whatever that has and 'i' before the name?

 

Aside from that, I'm starting to get the syntax down. But one thing that I have no clue about is why it seems some variables are declared as a bool or a long or whatever. It looks like it's assigning an object to a variable that is declared a boolean. Ex:

   Dim boolstatus as Boolean

   boolstatus = Part.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)

Is that not an object of some sort? I mean, it's holding more information than just True/False is it not?

 

Another example:

  Dim retval As Long

  Dim info As Long

  retval = swAssy.EditPart2(True, False, info)

Isn't a long an interger? Is EditPart2

 

How do I tell what type swAssy.EditPart2(True, False, info) is to assign it later? Looking at the API help page for EditPart2 it doesn't really get specific what it's returning. It just says Return Value: swEditPartSuccessful if Successful. Ok, that just tells me its either sending back a True for successful or False if not. But again, its type Long...

 

Much confused.

 

I have some experience with other actual programming languages, but VB(especially with SW) just isn't clicking. I've made a couple VBA userforms with excel, but wasn't really digging into this type of stuff and mostly googled and copy pasta'd what I needed and no problems.

 

I've been doing Solidworks's Premium E-Course on API fundamentals but here I am...

Outcomes