Select Case Syntax

Select Case Syntax

brad.jackson
Enthusiast Enthusiast
521 Views
2 Replies
Message 1 of 3

Select Case Syntax

brad.jackson
Enthusiast
Enthusiast

I am trying to set a part number in iProperties based on the cut length of the part.  We get this raw part in four different lengths and I need to set the part number according to the 'Track_Length' user parameter in the part.  I am getting errors when I hit a line that uses the 'And' operator.  I am using this method to define what to do if the value is between two values.

 

bradjackson_0-1659984302385.png

 

 

Any help would be greatly appreciated.

 

'5598 = 11'-0"
'1557 = 13'-0"
'1558 = 17'-0"
'1559 = 21'-0" 
'Set track part number in iProperties based on part length.
Select Case TRACK_LENGTH
Case TRACK_LENGTH <= 132
iProperties.Value("Project", "Part Number") = "5598"
Case TRACK_LENGTH > 132 And <= 156
iProperties.Value("Project", "Part Number") = "1557"
'Case TRACK_LENGTH > 156 And <= 204
'iProperties.Value("Project", "Part Number") = "1558"
'Case TRACK_LENGTH > 204 And <= 252
'iProperties.Value("Project", "Part Number") = "1558"
End Select 

 

 

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

JelteDeJong
Mentor
Mentor
Accepted solution

you can try it like this

Dim inch11 = 11 * 25.4 '5598 = 11'-0"
Dim inch13 = 13 * 25.4 '1557 = 13'-0"
Dim inch17 = 17 * 25.4 '1558 = 17'-0"
Dim inch21 = 21 * 25.4 '1559 = 21'-0" 

'Set track part number in iProperties based on part length.
Select Case True
    Case TRACK_LENGTH <= inch11
        iProperties.Value("Project", "Part Number") = "5598"
    Case inch11 < TRACK_LENGTH And TRACK_LENGTH <= inch13
        iProperties.Value("Project", "Part Number") = "1557"
    Case inch13 < TRACK_LENGTH And TRACK_LENGTH <= inch17
        iProperties.Value("Project", "Part Number") = "1558"
    Case inch17 < TRACK_LENGTH And TRACK_LENGTH <= inch21
        iProperties.Value("Project", "Part Number") = "1558"
End Select

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 3

brad.jackson
Enthusiast
Enthusiast

Thanks for the help.  What I actually noticed from your example was that I did not have my variable before the second argument on lines {9, 11, and 13}.  Once I added them it worked like a charm.

 

Select Case True
	Case TRACK_LENGTH <= "132"
		iProperties.Value("Project", "Part Number") = "5598"
	Case TRACK_LENGTH > "132" And TRACK_LENGTH <= "156"
		iProperties.Value("Project", "Part Number") = "1557"
	Case TRACK_LENGTH > 156 And TRACK_LENGTH <= 204
		iProperties.Value("Project", "Part Number") = "1558"
	Case TRACK_LENGTH > 204 And TRACK_LENGTH <= 252
		iProperties.Value("Project", "Part Number") = "1559"
End Select
0 Likes