Yes or No question, No isn't registering

Yes or No question, No isn't registering

AMN3161
Advocate Advocate
506 Views
2 Replies
Message 1 of 3

Yes or No question, No isn't registering

AMN3161
Advocate
Advocate

I been staring at this for a while, doesn't anyone know why my VBNo is not registering when the dialog box comes up?

 

If System.IO.File.Exists(iProperties.Value("Custom", "Project_ Excel_File_Name")) = False Then

	Question5 = MessageBox.Show("The Project BOM was renamed or has been moved, Want to show me where is? If not I will make the link Inactive ", "iLogic Question", MessageBoxButtons.YesNo)

If Question5 = vbYes Then
				Dim oFileDlg1E As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg1E)
oFileDlg1E.InitialDirectory = oOrigRefName1E
oFileDlg1E.CancelError = True
On Error Resume Next
oFileDlg1E.ShowOpen()
If Err.Number <> 0 Then
Return
ElseIf oFileDlg1E.FileName <> "" Then
selectedfile1E = oFileDlg1E.FileName

End If

MessageBox.Show("You selected: " & selectedfile1E, "iLogic")
iProperties.Value("Custom", "Project_ Excel_File_Name") = selectedfile1E

End If

    Dim oAsm1F As AssemblyDocument = ThisDoc.Document
	Dim oDef1F As AssemblyComponentDefinition = oAsm1F.ComponentDefinition
	Dim pName1F As String = "Project_BOM" 'Property name here
	For Each oRefDoc1F As Document In oAsm1F.AllReferencedDocuments
	If oRefDoc1F.DocumentType = DocumentTypeEnum.kPartDocumentObject _
		AndAlso oDef1F.Occurrences.AllReferencedOccurrences(oRefDoc1F).Count > 0
		On Error Resume Next
		oRefDoc1F.PropertySets("Inventor User Defined Properties")(pName1F).Value = iProperties.Value("Custom", "Project_ Excel_File_Name")
	
End If
	
	Next
	

Else If Question5 = vbNo Then
	
    MessageBox.Show("Do Stuff", "Title")

	
	End If
0 Likes
Accepted solutions (1)
507 Views
2 Replies
Replies (2)
Message 2 of 3

J-Camper
Advisor
Advisor
Accepted solution

You had an End If separating the vbYes and vbNo If statements.  I added named lines relating to the If Statements for clarity:

I1:If System.IO.File.Exists(iProperties.Value("Custom", "Project_ Excel_File_Name")) = False Then

	Question5 = MessageBox.Show("The Project BOM was renamed or has been moved, Want to show me where is? If not I will make the link Inactive ", "iLogic Question", MessageBoxButtons.YesNo)

I2a:If Question5 = vbYes Then
		Dim oFileDlg1E As Inventor.FileDialog = Nothing
		InventorVb.Application.CreateFileDialog(oFileDlg1E)
		oFileDlg1E.InitialDirectory = oOrigRefName1E
		oFileDlg1E.CancelError = True
		On Error Resume Next
		oFileDlg1E.ShowOpen()
I3a:	If Err.Number <> 0 Then
			Return
I3b:	ElseIf oFileDlg1E.FileName <> "" Then
			selectedfile1E = oFileDlg1E.FileName
E3:		End If

		MessageBox.Show("You selected: " & selectedfile1E, "iLogic")
		iProperties.Value("Custom", "Project_ Excel_File_Name") = selectedfile1E

	'End If 'removed this end to join with Else If Below

	    Dim oAsm1F As AssemblyDocument = ThisDoc.Document
		Dim oDef1F As AssemblyComponentDefinition = oAsm1F.ComponentDefinition
		Dim pName1F As String = "Project_BOM" 'Property name here
		For Each oRefDoc1F As Document In oAsm1F.AllReferencedDocuments
L4:			If oRefDoc1F.DocumentType = DocumentTypeEnum.kPartDocumentObject _
				AndAlso oDef1F.Occurrences.AllReferencedOccurrences(oRefDoc1F).Count > 0
				On Error Resume Next
				oRefDoc1F.PropertySets("Inventor User Defined Properties")(pName1F).Value = iProperties.Value("Custom", "Project_ Excel_File_Name")
			
E4:			End If
		Next
I2b:Else If Question5 = vbNo Then
	    MessageBox.Show("Do Stuff", "Title")
E2:	End If 'Added End If 
E1:End If

I# - If started

E# - If closed

 

0 Likes
Message 3 of 3

AMN3161
Advocate
Advocate

Thank you, was just staring at this for so long i must of just missed that

 

 

0 Likes