I have a macro which takes an input from a user form text box and stores it as a Double. I need a way to test the input to make sure it is numerical before storing it, as it crashes the macro if the user enters a non-numerical input. Is there a simple way to test for numerical input? Thanx.
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Hi LonesomeJoe,
You can use IsNumeric for this.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Here's an iLogic example.
oInput = InputBox("Enter a number", "iLogic", "") numericCheck = IsNumeric(oInput) If numericCheck = True Then MessageBox.Show("Input is numeric", "iLogic") Else MessageBox.Show("Input is NOT numeric.", "iLogic") End If
VBA example:
Public Sub NumericCheck() oInput = InputBox("Enter a number", "iLogic", "") Dim NumericCheck As Boolean NumericCheck = IsNumeric(oInput) If NumericCheck = True Then MsgBox ("Input is numeric") Else MsgBox ("Input is NOT numeric.") End If End Sub
Thanx, Curtis! I knew there was a way to do this but I could not remember WHAT it was! Thanx.
Is there a way to get the numeric value from the InputBox and start PartsListNumber from that or add it to the PartsListNumber? I found some code that takes all of the parts lists from a DWG and creates a new tab in Excel for each instance but I would like to have some control over the numbering of the tabs so that the tabs align with the actual location/floor level on our project. See the code below.
oInput = InputBox("Input the first floor level number below", "First Floor Level", "") numericCheck = IsNumeric(oInput) If numericCheck = True Then MessageBox.Show("Input is numeric", "iLogic") Else MessageBox.Show("Input is NOT numeric.", "iLogic") End If 'specify the start cell oOptions.Value("StartingCell") = "A" & startRow 'specify the XLS tab name 'here the file name is used oOptions.Value("TableName") = "Embeds For Level-" & PartsListNumber 'without extension 'choose to include the parts list title row 'in this example "Ye Old List of Parts" is written to the StartingCell oOptions.Value("IncludeTitle") = False 'choose to autofit the column width in the xls file oOptions.Value("AutoFitColumnWidth") = True ' export the Partslist to Excel with options oPartslist.Export(fileName, PartsListFileFormatEnum.kMicrosoftExcel, oOptions) PartsListNumber = PartsListNumber + 1
Have you tried Val("StringNumericalValue"), or CDblAny("StringNumericalValue"). Both of those are in the 'System' iLogic snippets, under Strings. But both are for returning Double (not Integer) data type from a String. You could then attempt to convert the Double to an Integer using something like CInt() or Int(), also both in the System snippets under Math.
Wesley Crihfield
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.