Message 1 of 3
Creating CommandMethod from existing function
Not applicable
07-03-2018
12:19 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey all,
I'm working on some VB.NET commands. I find that I have a series of commands that are really repetitive codewise, with only three pieces of information different. I'd like to store those pieces of information in an array to make them quickly changeable and just iterate through them, creating a command for each one that calls the same function, just passing in those pieces of information.
'Inserts a Source Four 19 degree on the next mouse click
<CommandMethod("ins19")> Public Sub cmdIns19()
InsertBlock("19blockname", "19blocklocation")
End Sub
'Inserts a Source Four 26 degree on the next mouse click
<CommandMethod("ins26")> Public Sub cmdIns26()
InsertBlock("26blockname", "26blocklocation")
End SubThe code above is an example, it's going to just repeat for every single block.
Is there a way to create that differently so I'm not repeating that code and I can just pull the information from a data structure that's a little more manageable?