Less than or equal too

Less than or equal too

AMN3161
Advocate Advocate
991 Views
8 Replies
Message 1 of 9

Less than or equal too

AMN3161
Advocate
Advocate

I think i am missing something really small but i cant find it for the life of me

I want the first if statement run if NUMBER_OF_TAGS is less then 49 and it its higher than 49 run the else if statement but for some reason my else if statement is activating before my first if statement

 

 

MessageBox.Show("Browse to Excel with the Tag Numbers","File Location", MessageBoxButtons.OK)
iLogicVb.RunRule("Excel_Location")
MessageBox.Show("Browse to where you want the DXFs or PDFs exported to", "File Location", MessageBoxButtons.OK)
iLogicVb.RunRule("DXF_Location")
iProperties.Value("Custom", "NUMBER_OF_TAGS") = InputBox("How many tags are there?", "Tag Quantity", "Numerical Number Only")

question = MessageBox.Show("Do you want to preview the DXF as a PDF before exporting?", "iLogic Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
	If question = vbYes & iProperties.Value("Custom", "NUMBER_OF_TAGS") <= "49"  Then
		iProperties.Value("Custom", "Tag_1") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A1")
		iProperties.Value("Custom", "Tag_1") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A2")
		iProperties.Value("Custom", "Tag_3") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A3")
		iProperties.Value("Custom", "Tag_4") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A4")
		iProperties.Value("Custom", "Tag_5") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A5")
		iProperties.Value("Custom", "Tag_6") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A6")
		iProperties.Value("Custom", "Tag_7") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A7")
		iProperties.Value("Custom", "Tag_8") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A8")
		iProperties.Value("Custom", "Tag_9") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A9")
		iProperties.Value("Custom", "Tag_10") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A10")
		iProperties.Value("Custom", "Tag_11") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A11")
		iProperties.Value("Custom", "Tag_12") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A12")
		iProperties.Value("Custom", "Tag_13") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A13")
		iProperties.Value("Custom", "Tag_14") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A14")
		iProperties.Value("Custom", "Tag_15") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A15")
		iProperties.Value("Custom", "Tag_16") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A16")
		iProperties.Value("Custom", "Tag_17") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A17")
		iProperties.Value("Custom", "Tag_18") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A18")
		iProperties.Value("Custom", "Tag_19") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A19")
		iProperties.Value("Custom", "Tag_20") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A20")
		iProperties.Value("Custom", "Tag_21") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A21")
		iProperties.Value("Custom", "Tag_22") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A22")
		iProperties.Value("Custom", "Tag_23") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A23")
		iProperties.Value("Custom", "Tag_24") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A24")
		iProperties.Value("Custom", "Tag_25") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A25")
		iProperties.Value("Custom", "Tag_26") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A26")
		iProperties.Value("Custom", "Tag_27") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A27")
		iProperties.Value("Custom", "Tag_28") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A28")
		iProperties.Value("Custom", "Tag_29") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A29")
		iProperties.Value("Custom", "Tag_30") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A30")
		iProperties.Value("Custom", "Tag_31") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A31")
		iProperties.Value("Custom", "Tag_32") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A32")
		iProperties.Value("Custom", "Tag_33") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A33")
		iProperties.Value("Custom", "Tag_34") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A34")
		iProperties.Value("Custom", "Tag_35") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A35")
		iProperties.Value("Custom", "Tag_36") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A36")
		iProperties.Value("Custom", "Tag_37") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A37")
		iProperties.Value("Custom", "Tag_38") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A38")
		iProperties.Value("Custom", "Tag_39") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A39")
		iProperties.Value("Custom", "Tag_40") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A40")
		iProperties.Value("Custom", "Tag_41") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A41")
		iProperties.Value("Custom", "Tag_42") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A42")
		iProperties.Value("Custom", "Tag_43") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A43")
		iProperties.Value("Custom", "Tag_44") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A44")
		iProperties.Value("Custom", "Tag_45") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A45")
		iProperties.Value("Custom", "Tag_46") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A46")
		iProperties.Value("Custom", "Tag_47") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A47")
		iProperties.Value("Custom", "Tag_48") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A48")
		iProperties.Value("Custom", "Tag_49") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A49")

		InventorVb.DocumentUpdate()
		
		ActiveSheet.View("DXF_View_Sheet1").View.Suppressed = False
		ActiveSheet.View("PDF_View_Sheet1").View.Suppressed = True
		
		Dim Time As DateTime = DateTime.Now
		Dim Format As String = "yyyyMdHHmm"
		iProperties.Value("Custom", "CURRENT_DATE") = Time.ToString(Format)

		file_path = iProperties.Value("Custom", "DXF_LOCATION")
		file_name = iProperties.Value("Custom", "CURRENT_DATE") & " Sheet 1"
		file_name_path = file_path & "\" & file_name

		ThisDoc.Document.SaveAs(file_name_path & ".pdf", True)
		
		ActiveSheet.View("DXF_View_Sheet1").View.Suppressed = True
		ActiveSheet.View("PDF_View_Sheet1").View.Suppressed = False
		
	Else If question = vbYes & iProperties.Value("Custom", "NUMBER_OF_TAGS") >= "49" Then
		MessageBox.Show("Sorry i am not ready to go higher than 49 right now", "Title")

Else If question = vbNo Then
		 
	End If
0 Likes
Accepted solutions (2)
992 Views
8 Replies
Replies (8)
Message 2 of 9

WCrihfield
Mentor
Mentor

Which set is the exact number 49 supposed to be a part of?  You need to get rid of the = sign from one of those two lines of code.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 9

WCrihfield
Mentor
Mentor
Accepted solution

@AMN3161 

Example:

If oNum <= 49 Then 'do something

ElseIf oNum > 49 Then 'do something else.

Notice the second statements is just > and not >=.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 9

AMN3161
Advocate
Advocate

wow, cant believe i missed that

 

thank you

0 Likes
Message 5 of 9

AMN3161
Advocate
Advocate

I dont understand, even after removing the = from the 2nd statement it still causes the 2nd statement to trigger when it shouldn't

 

MessageBox.Show("Browse to Excel with the Tag Numbers","File Location", MessageBoxButtons.OK)
iLogicVb.RunRule("Excel_Location")
MessageBox.Show("Browse to where you want the DXFs or PDFs exported to", "File Location", MessageBoxButtons.OK)
iLogicVb.RunRule("DXF_Location")
iProperties.Value("Custom", "NUMBER_OF_TAGS") = InputBox("How many tags are there?", "Tag Quantity", "Numerical Number Only")

question = MessageBox.Show("Do you want to preview the DXF as a PDF before exporting?", "iLogic Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
	If question = vbYes & iProperties.Value("Custom", "NUMBER_OF_TAGS") <= "49"  Then
		iProperties.Value("Custom", "Tag_1") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A1")
		iProperties.Value("Custom", "Tag_1") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A2")
		iProperties.Value("Custom", "Tag_3") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A3")
		iProperties.Value("Custom", "Tag_4") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A4")
		iProperties.Value("Custom", "Tag_5") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A5")
		iProperties.Value("Custom", "Tag_6") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A6")
		iProperties.Value("Custom", "Tag_7") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A7")
		iProperties.Value("Custom", "Tag_8") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A8")
		iProperties.Value("Custom", "Tag_9") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A9")
		iProperties.Value("Custom", "Tag_10") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A10")
		iProperties.Value("Custom", "Tag_11") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A11")
		iProperties.Value("Custom", "Tag_12") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A12")
		iProperties.Value("Custom", "Tag_13") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A13")
		iProperties.Value("Custom", "Tag_14") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A14")
		iProperties.Value("Custom", "Tag_15") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A15")
		iProperties.Value("Custom", "Tag_16") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A16")
		iProperties.Value("Custom", "Tag_17") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A17")
		iProperties.Value("Custom", "Tag_18") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A18")
		iProperties.Value("Custom", "Tag_19") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A19")
		iProperties.Value("Custom", "Tag_20") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A20")
		iProperties.Value("Custom", "Tag_21") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A21")
		iProperties.Value("Custom", "Tag_22") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A22")
		iProperties.Value("Custom", "Tag_23") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A23")
		iProperties.Value("Custom", "Tag_24") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A24")
		iProperties.Value("Custom", "Tag_25") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A25")
		iProperties.Value("Custom", "Tag_26") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A26")
		iProperties.Value("Custom", "Tag_27") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A27")
		iProperties.Value("Custom", "Tag_28") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A28")
		iProperties.Value("Custom", "Tag_29") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A29")
		iProperties.Value("Custom", "Tag_30") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A30")
		iProperties.Value("Custom", "Tag_31") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A31")
		iProperties.Value("Custom", "Tag_32") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A32")
		iProperties.Value("Custom", "Tag_33") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A33")
		iProperties.Value("Custom", "Tag_34") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A34")
		iProperties.Value("Custom", "Tag_35") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A35")
		iProperties.Value("Custom", "Tag_36") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A36")
		iProperties.Value("Custom", "Tag_37") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A37")
		iProperties.Value("Custom", "Tag_38") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A38")
		iProperties.Value("Custom", "Tag_39") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A39")
		iProperties.Value("Custom", "Tag_40") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A40")
		iProperties.Value("Custom", "Tag_41") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A41")
		iProperties.Value("Custom", "Tag_42") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A42")
		iProperties.Value("Custom", "Tag_43") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A43")
		iProperties.Value("Custom", "Tag_44") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A44")
		iProperties.Value("Custom", "Tag_45") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A45")
		iProperties.Value("Custom", "Tag_46") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A46")
		iProperties.Value("Custom", "Tag_47") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A47")
		iProperties.Value("Custom", "Tag_48") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A48")
		iProperties.Value("Custom", "Tag_49") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A49")

		InventorVb.DocumentUpdate()
		
		ActiveSheet.View("DXF_View_Sheet1").View.Suppressed = False
		ActiveSheet.View("PDF_View_Sheet1").View.Suppressed = True
		
		Dim Time As DateTime = DateTime.Now
		Dim Format As String = "yyyyMdHHmm"
		iProperties.Value("Custom", "CURRENT_DATE") = Time.ToString(Format)

		file_path = iProperties.Value("Custom", "DXF_LOCATION")
		file_name = iProperties.Value("Custom", "CURRENT_DATE") & " Sheet 1"
		file_name_path = file_path & "\" & file_name

		ThisDoc.Document.SaveAs(file_name_path & ".pdf", True)
		
		ActiveSheet.View("DXF_View_Sheet1").View.Suppressed = True
		ActiveSheet.View("PDF_View_Sheet1").View.Suppressed = False
		
	Else If question = vbYes & iProperties.Value("Custom", "NUMBER_OF_TAGS") > "49" Then
		MessageBox.Show("Sorry i am not ready to go higher than 49 right now", "Title")

Else If question = vbNo Then
		 
	End If

 

0 Likes
Message 6 of 9

WCrihfield
Mentor
Mentor

Why is 49 in quotation marks?  Maybe that's why.  It's probably trying to evaluate a String in both cases, and both strings are the same string, so they're equal to each other.  Try removing the quotation marks.  If the value of that iProperty is a String, you can use CDbl(oiPropertyValue) to convert the string to a Double, or CInt() to convert it to an Integer.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 9

AMN3161
Advocate
Advocate

I attached the document

 

I tried switching the number of tags line to a unitless parameter rather than a custom iproperty  and it didnt fixed it, not its just activating the 1st set of code regardless if the value is higher or lower than 49

 

the rule is called "Prompts"

 

when running the rule its going to ask for you a excel just give it the one i attached

0 Likes
Message 8 of 9

WCrihfield
Mentor
Mentor
Accepted solution

Try changing the line

If question = vbYes & NUMBER_OF_TAGS_PAR <= 49  Then

to

If question = vbYes And NUMBER_OF_TAGS_PAR <= 49  Then

And change

Else If question = vbYes & NUMBER_OF_TAGS_PAR > 49 Then

to

Else If question = vbYes And NUMBER_OF_TAGS_PAR > 49 Then

Notice I changed & to And.  & is used within Strings, to put multiple pieces of text together.  And is a logical term of inclusion.  You can't use & in place of And.

After I made this change, I got the second message box to show.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 9 of 9

AMN3161
Advocate
Advocate

I figured it was something small, thank you for the help! works great!

0 Likes