Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Test an input value for number

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
1988 Views, 4 Replies

Test an input value for number

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.

4 REPLIES 4
Message 2 of 5
Curtis_Waguespack
in reply to: Anonymous

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

 

 

Message 3 of 5
Anonymous
in reply to: Curtis_Waguespack

Thanx, Curtis!  I knew there was a way to do this but I could not remember WHAT it was!  Thanx.

Message 4 of 5

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
Message 5 of 5
WCrihfield
in reply to: estringer

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

EESignature

(Not an Autodesk Employee)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report