iLogic end of statement error in Try

iLogic end of statement error in Try

mrawesomelemons
Enthusiast Enthusiast
1,078 Views
2 Replies
Message 1 of 3

iLogic end of statement error in Try

mrawesomelemons
Enthusiast
Enthusiast

I am trying to set the display name in the browser of parts and assemblies.

I got it working but parts with an empty ModelType it generates an error. Trying to elminate this with a Try and Catch statement returns an error "End of statement expected" in the line with "Try z1 = True"

 

'create reference to part
oDoc = ThisApplication.ActiveDocument

modelFileNamewithoutextension = IO.Path.GetFileNameWithoutExtension(ThisDoc.FileName)	'Set filename without file extension
Dim x As Boolean = ThisDoc.FileName.Contains("FHE")										'Create variable of filename containing FHE
Dim y As String = iProperties.Value("Project", "Part Number")							'Create variable from part number
Dim y1 As Boolean = String.IsNullOrEmpty(y)												'Variable of empty part number
Dim z As String = iProperties.Value("CUSTOM", "AIMD_ITEM_MODEL_TYPE")					'Create variable of AN/KEY
Dim z1 As Boolean = String.IsNullOrEmpty(z)												'Variable of empty AN/KEY

Try z1 = True																			'Check if AN/KEY is empty
Catch
	Return  																			'Exit from the rule
End Try

If x = False And y1 = False																'If filename does not contain FHE and part number is not empty
	oDoc.DisplayName = iProperties.Value("Project", "Part Number") & "/" & iProperties.Value("Project", "Revision Number") & " - " & iProperties.Value("Summary", "Title") & " - " & modelFileNamewithoutextension
Else
	oDoc.DisplayName = z & "/" & iProperties.Value("Project", "Revision Number") & " - " & iProperties.Value("Summary", "Title") & " - " & modelFileNamewithoutextension
End If
iLogicVb.UpdateWhenDone = True

 Does anyone know how to fix this?

0 Likes
Accepted solutions (1)
1,079 Views
2 Replies
Replies (2)
Message 2 of 3

philip1009
Advisor
Advisor
Accepted solution

You can't have any code after the Try, you need to put it on the next line:

 

SyntaxEditor Code Snippet

Try
	z1 = True
Catch
	Return
End Try
0 Likes
Message 3 of 3

mrawesomelemons
Enthusiast
Enthusiast

Derp. I did not know that. Thank you!