I have declared some variables as inventor parameters like so:
Dim OffsetLeft As Inventor.Parameter = oParams.Item("offsetleft")
Dim OffsetRight As Inventor.Parameter = oParams.Item("offsetright")
Dim ISX As Inventor.Parameter = oParams.Item("isx)
Then a little later I use them in this equation, which is where I get the error "Conversion from string "17.5 mm" to type 'Double' is not valid.
ISX.Expression = (CaseWidth - OffsetLeft.Expression - OffsetRight.Expression - 4) / BayNumberX
17.5 mm being the value of OffsetLeft and OffsetRight. The other parameters are numerical User Parameters.
Do I need to convert OffsetLeft and OffsetRight to numerical values? If so, how do I do it?
Solved! Go to Solution.
Solved by pball. Go to Solution.
Solved by HermJan.Otterman. Go to Solution.
I think you should use OffsetLeft.Value instead of OffsetLeft.expression.
mind the unit, VB works in cm
Even I am getting the same error: "conversion from string to type, double is not valid" with the below code, when I am trying input anything other than numbers. Please could someone help me in solving this error.
Dim list As New ArrayList list = MultiValue.List("Part_Name") Dim msgl As String = vbCrLf & vbCrLf For Each sVal As String In list msgl += sVal & vbCrLf Next Dim val As String = InputBox("Enter new member name" & msgl, "Adding Val to List", New_Part_name) If val = 0 Or val Is Nothing Then Exit Sub If list.Contains(val) = False Then list.Add(val) MultiValue.List("Part_Name") = list
Hi @Sharon_Menachery_782W9QAH4BU8. What is the purpose of your code example? I assume it is throwing the error for Line 9, where you are first attempting to check the value of a String type variable against a numeric zero, which will not work. In that case, it is either attempting to convert a String into an Integer (or similar numeric data Type), or trying to convert the numeric data Type to a String, before it can do the comparison. If the zero had quotes around it, then it might have worked OK, but not with a raw numerical value. Checking a String against 'Nothing' is OK, and will work, but is not typical. The most common way to check if the value you get back from an InputBox is to check against an empty String (""). We can also use the String.Empty property the same way. However, there is also another vb.net tool that we can use in cases when the String may actually be 'Null' instead of simply empty. String.IsNullOrEmpty(), then there is the constant vbNullString.
Wesley Crihfield
(Not an Autodesk Employee)
@Sharon_Menachery_782W9QAH4BU8 wrote:Dim val As String = InputBox("Enter new member name" & msgl, "Adding Val to List", New_Part_name)
Side-note, it's not considered good practice to name your own variables identical to existing operators/functions (VAL).
Can't find what you're looking for? Ask the community or share your knowledge.