Dim exp_1 As Expression = Nothing
Dim exp1Value As Double = 2.7182
Try
'create expression, type: Number [constant] (unitless)
'.Create method will not work to create an expression of type String
exp_1 = workPart.Expressions.Create("NXJ_1 = " & exp1Value.ToString)
'alternately, let the compiler convert the value to a string
'exp_1 = workPart.Expressions.Create("NXJ_1 = " & exp1Value)
'or, pass in the value directly
'exp_1 = workPart.Expressions.Create("NXJ_1 = 2.7182")
Catch ex As NXException
[highlight #FCE94F] If ex.ErrorCode = 1050017 Then
'expression already exists[/highlight]
exp_1 = workPart.Expressions.FindObject("NXJ_1")
Else
'other error
lw.WriteLine("NX exception: " & ex.ErrorCode & ", " & ex.Message)
End If
End Try