- First, get a comprehensive list of the properties you wish to use, and decide how long each one is allowed to be
- In the Initialize Subroutine, change the default autobuilt .ini file.
leave the options for controlling the application's preferences-
ts.write "[rebuild]" + vbCrLf '11
ts.write "#invisible" + vbCrLf
ts.write "visible" + vbCrLf
ts.write "#unchecked" + vbCrLf
ts.write "checked" + vbCrLf
ts.write vbCrLf
ts.write "[autofill]" + vbCrLf '12
ts.write "existing" + vbCrLf
ts.write "#comment out above value to use defaults instead" + vbCrLf
ts.write vbCrLf
ts.write "[global_config]" + vbCrLf '0
ts.write "#the config file path must be the first option." + vbCrLf
ts.write "#then one of the configuration modes should be selected. (uncommented)" + vbCrLf
ts.write "#path to config file" + vbCrLf
ts.write "#global_config_overrides_local" + vbCrLf
ts.write "#local_config_overrides_global" + vbCrLf
ts.write "#global_config_added_to_local" + vbCrLf
ts.write "#local_config_added_to_global" + vbCrLf
ts.write vbCrLf
But change all the rest, if neccesary. ie- change:
ts.write "[title1]" + vbCrLf '0
ts.write "#hardcoded max length is 25" + vbCrLf
ts.write "<title1>" + vbCrLf 'the default value...is <title1>, not title1
ts.write vbCrLf
To-
ts.write "[myproperty]" + vbCrLf '0
ts.write "#hardcoded max length is 25" + vbCrLf
ts.write "cheese" + vbCrLf
ts.write vbCrLf
- In the beginning of the Initialize Subroutine, there is a check to see
if you have a solidworks drawing. If you would like to use this with
part files, comment this out:
If Drawing.GetType <> swDocDRAWING Then ' Check to see if a document is loaded.
msg = "Must be a Drawing - Load Drawing and Reinitialize"
Style = vbExclamation ' Error style dialog
Title = "BOM" ' Define title
Call MsgBox(msg, Style, Title) ' Display error message
Exit Sub ' If no model currently loaded, then exit
End If
- Toward the end of the Initialization Routine, there is a section
that parses out properties from the ini file, and puts them in a particular order
in the Fieldname array. change my properties to yours.-
'find [title1] in array and move row to pos 0
If IniArray(i, 0) = "title1" Then
For j = 0 To MAXLENGTH
temparray(0, j) = IniArray(i, j)
Next j
End If
Will put title1 in the first slot in the Fieldname array. change to:
'find [myproperty] in array and move row to pos 0
If IniArray(i, 0) = "mypropery" Then
For j = 0 To MAXLENGTH
temparray(0, j) = IniArray(i, j)
Next j
End If
...and your property will be there instead
- At the end of Initialization, The Form's components (textboxes, combolists)are
filled out with values from the Fieldname array. You'll at least want
to change the comments if you change properties. ie.-
Text2.Text = Fieldname(0, 2) 'title1
should change to:
Text2.Text = Fieldname(0, 2) 'mypropery
Note that the "0" above is the "slot" you put your propery into
when you changed the parse options. If myproperty2 is in slot 7,
it reads:
Text2.Text = Fieldname(7, 2) 'mypropery2
Done with initialization- almost done!
- Both the Defaults_Button_Click and Existing_Button_Click sections
need to be copy and pasted from the section you just modified.
there's a short section at the beginning of each that you need to keep though.
or you could make it into a separate subroutine.
- Finally, in Command1_Click, change values to your properties, making sure
that you get the values from the right textbox or combobox.
- Compile. OK, I'm sorry, that's harder than it needs to be.
did I mention that this is my first VB Program?
- Compile .nsi file. read the NSIS help if you have problems.
On windows, this may be as simple as Right-Clicking and selecting
"Compile .nsi".