How can I parse a string like a parameter does?

How can I parse a string like a parameter does?

MTheDesigner
Advocate Advocate
218 Views
1 Reply
Message 1 of 2

How can I parse a string like a parameter does?

MTheDesigner
Advocate
Advocate

Hey all,

 

I am writing some code where the user needs to enter a string. Right now my string is only ever interpreted as inches. how can I give it inputs like " 4' 3 1/4" " and have it know what I am taking about. Parameters already do this so the code must be somewhere in the program already. 

 

Regards.

0 Likes
219 Views
1 Reply
Reply (1)
Message 2 of 2

Michael.Navara
Advisor
Advisor

You need to parse your string using UnitsOfMeasure.GetValueFromExpression Method

 

Dim part As PartDocument = ThisDoc.Document
Dim expr As String = " 4' 3 1/4"""
Dim val = part.UnitsOfMeasure.GetValueFromExpression(expr, "mm")
Logger.Debug(val)