MessageBox output: To get No button activated

MessageBox output: To get No button activated

RoyWickrama_RWEI
Advisor Advisor
855 Views
8 Replies
Message 1 of 9

MessageBox output: To get No button activated

RoyWickrama_RWEI
Advisor
Advisor

I rather like to get the No button activated instead of the Yes button: to avoid affecting data in case press ENTER button accidentally.

Could I get help.

 

Sub main()
oLFN_wExt_ModelDoc = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
Dim oAbsoluteModel As Document
oAbsoluteModel = ThisDoc.ModelDocument
oFFN_ThisDoc = oAbsoluteModel.FullFileName
oExtn_ModelDoc = Right(oFFN_ThisDoc, 4)
oCustomPropertySet_Model = oAbsoluteModel.PropertySets.Item("Inventor User Defined Properties")

'	Dim oDelete_Cust_iProps As New ArrayList
'	oDelete_Cust_iProps.Add("Delete - Yes")
'	oDelete_Cust_iProps.Add("Delete - No")
'	oDelete_YN = InputListBox("Prompt", oDelete_Cust_iProps, oDelete_Cust_iProps(0), Title := "Title", ListName := "List")

Dim nCutOff As Integer = 3
For Each oCust_iProperty In oCustomPropertySet_Model
Try 
	If oCust_iProperty.Name.Contains("REFD") Then 	'And oCust_iProperty.Name.Contains("QTY") Then
	oDelete_YN = MessageBox.Show("oCust_iProperty.Name: " & oCust_iProperty.Name _
	& vbLf & "oCust_iProperty.Value: " & oCust_iProperty.Value, "DELETE(YES)/EDIT(NO)" _
	& vbLf & "YES - Delete" _
	& vbLf & "No - Edit", MessageBoxButtons.YesNo)
'		oDelete_Cust_iProps.Add()
		If oDelete_YN = vbYes Then
			oCust_iProperty.Value = ""
'			oCust_iProperty.Delete
		Else If oDelete_YN = vbNo Then
			oCust_iProperty.Value = InputBox("Edit: ", "EDIT VALUE", oCust_iProperty.Value)
		End If
		If oCust_iProperty.NAME.Contains("REFD03") Then
			MessageBox.Show("oCust_iProperty.NAME: " & oCust_iProperty.NAME, "Title")
		End If
'           	 		oProp = oCustomPropertySet.Item(oCust_iProperty)
'					oCustomPropertySet.Item(oCust_iProperty).Delete	'oCustProp.Delete
	End If
Catch
	'Do nothing
End Try
Next oCust_iProperty				
End Sub2019-06-30 21_46_06.png
0 Likes
Accepted solutions (3)
856 Views
8 Replies
Replies (8)
Message 2 of 9

Xun.Zhang
Alumni
Alumni

Hello @RoyWickrama_RWEI,

How about reverse the code logic to let Yes =edit and No = delete?


Xun
Message 3 of 9

-niels-
Mentor
Mentor
This might be interesting to read:
https://docs.microsoft.com/en-us/previous-versions//sfw6660x(v=vs.85)
or this one:
https://www.functionx.com/vb/functions/msgbox.htm

Not sure if messagebox.show allows for the defaultbutton option, so you might have to change it to msgbox for this to work.

Niels van der Veer
Inventor professional user & 3DS Max enthusiast
Vault professional user/manager
The Netherlands

Message 4 of 9

RoyWickrama_RWEI
Advisor
Advisor

Thanks for the suggestion. I had to do a little more work to make it somewhat user friendly so that I would know what to choose from (in case I forget - I do always) - see below.

 

2019-07-01 10_19_44-Window.png

 

0 Likes
Message 5 of 9

RoyWickrama_RWEI
Advisor
Advisor
Accepted solution

Attached is the code revised.2019-07-01 10_19_44-Window.png

Message 6 of 9

philip1009
Advisor
Advisor
Accepted solution

MessageBox in iLogic does support setting the default button to be highlighted:

 

MessageBox.Show("Question?", _

"Title", _

MessageBoxButtons.YesNo, _

MessageBoxIcon.Question, _

MessageBoxDefaultButton.Button1) '<---Or Button2

 

While in the rule editor, there's a tab at the top labeled "Wizards", there's a tool in there to create a message box the way you want and it will insert the code as needed, it also provides a preview button.

Message 7 of 9

RoyWickrama_RWEI
Advisor
Advisor

Thanks a lot. Looks like a good suggestion. I tried to get at it as follows without success.

Could you help me a bit more. Thanks.

 

'MessageBox.Show("Question?", _

'"Title", _

'MessageBoxButtons.YesNo, _

'MessageBoxIcon.Question, _

'MessageBoxDefaultButton.Button1) '<---Or Button2

MessageBox.Show("Message", "Title")


'MessageBox.Show("Message", "Title", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1, MessageBoxDefaultButton.Button2)
MessageBox.Show("Message", "Title", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2, MessageBoxDefaultButton.Button1)
0 Likes
Message 8 of 9

philip1009
Advisor
Advisor

You have default button in there twice where the fourth property is designated for your icon of choice, such as MessageBoxIcon.Question.

0 Likes
Message 9 of 9

RoyWickrama_RWEI
Advisor
Advisor
Accepted solution

I explored options available based on your suggestion.

Thanks for the help.

 

Dim oPath_ThisDoc As String = ThisDoc.Path


oMsg_Input = MessageBox.Show(oPath_ThisDoc, "Title3", MessageBoxButtons.YesNoCancel, MessageBoxIcon.None, MessageBoxDefaultButton.Button3)



'MessageBox.Show(oPath_ThisDoc, "Title2", MessageBoxButtons.OKCancel) ',MessageBoxDefaultButton.Button2)
'MessageBox.Show(oPath_ThisDoc, "Title3", MessageBoxButtons.YesNoCancel, MessageBoxIcon.None, MessageBoxDefaultButton.Button2) ',MessageBoxDefaultButton.Button2)

'MessageBox.Show(oPath_ThisDoc, "Title4", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)

'MessageBox.Show(oPath_ThisDoc, "Title5", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2)

'MessageBox.Show(oPath_ThisDoc, "Title6", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2)


'MessageBox.Show(oPath_ThisDoc, "Title7", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2)

'MessageBox.Show(oPath_ThisDoc, "Button 8-1", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)


'MessageBox.Show(oPath_ThisDoc, "Button 8-2", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2)
'MessageBox.Show(oPath_ThisDoc, "Button 8-3", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button3)

 

 

0 Likes