Hello,
I wrote a program to allow users at my company to input custom values into their parts, assemblies, and drawings. But I've found a small bug and can't seem to find any information on how to do fix this.
What it does:
When a user inputs a numerical value for "Price", the code adds a "\\\$" before it saves the property. This ensures that the user will include a dollar symbol. However, if there is a "\\\$" already there, it still adds one.
What I want it to do:
Check the string Price.Text before inserting the \\\$ and only include a \\\$ if it's missing.
I just can't figure out how to check the first letter of the string and compare that to \\\$. I assume I need an If Then statement. Any help would be greatly appreciated.
Thanks,
Tara
P.S. I'm using Solidworks 2010 x64 bit
SolidworksApi macros
VBA has a lot of handy string handling functions built in. Check VBA help for things like Left, Right, Mid, Instr, Strcomp, InStrRev, etc.
In this particular case, if your variable is called "Price":
if Not (Left(Price, 1) = "$") Then
Price = "$" & Price
end if
Thank you! It works great now.
-Tara