3 radio buttons instead of 2 in a messagebox?

3 radio buttons instead of 2 in a messagebox?

SharkDesign
Mentor Mentor
1,850 Views
5 Replies
Message 1 of 6

3 radio buttons instead of 2 in a messagebox?

SharkDesign
Mentor
Mentor

The standard code is setup as a boolean so there's only two options, is there a way to have 3?

 

booleanParam = InputRadioBox("Prompt", "Button1 Label", "Button2 Label", booleanParam, Title := "Title")

 

I know you can launch a global form and do it that way, but I don't want to clutter the global form tab.

You can use inputlist, but I find that messagebox really ugly. 

  Inventor Certified Professional
0 Likes
Accepted solutions (2)
1,851 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor

Yes you can.  Just not with an InputRadioBox.  If you don't need textual or selection functionality, and just need 3 button functionality, you can use a regular MessageBox.Show() or MsgBox(), then specify that it has 3 buttons (for example Yes, No, & Cancel or Abort, Retry, & Ignore).  You can't change the labels of those buttons, but you can check the MsgBoxResult afterwords to determine which button the user clicked (if any) and decide what to do about each possible button click.  I have done this many times.  Of course, I usually have a multi-line message describing what each button click will do, if other users will be interacting with it.

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡 or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 6

WCrihfield
Mentor
Mentor

Here is a quickie example of what that might look like in an iLogic rule, using the MsgBox route.

oAns = MsgBox("Click [YES] to ..." & vbCrLf & _
"Click [NO] to ..." & vbCrLf & _
"Click [CANCEL] to ...", vbYesNoCancel + vbQuestion, "CHOOSE ONE")
If oAns = vbYes Then
	MsgBox("You clicked the [YES] button.", , "")
	'or do something
ElseIf oAns = vbNo Then
	MsgBox("You clicked the [NO] button.", , "")
	'or do something else
ElseIf oAns = vbCancel Then
	MsgBox("You clicked the [CANCEL] button.", , "")
	'or do something else
End If

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 6

WCrihfield
Mentor
Mentor
Accepted solution

Just another option, but definitely a more complicated one.  If you don't want to use a iLogic Form, or VBA UserForm, but you really need the buttons to have custom labels, and maybe need a more intuitive way of responding to each possible button click, you could create your own Windows Form right within the rule code.  Here is a link to one of my contribution posts where I demonstrate this (and another example).  It can get complicated, but can be very nice when its done.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 6

Curtis_Waguespack
Consultant
Consultant
Accepted solution

 Hi @SharkDesign 

 

Here is an example that is a modification of a checkbox example that I saw recently, provided by @JelteDeJong 

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

 

 

AddReference "System.Drawing"
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Public Class WinForm
	Inherits System.Windows.Forms.Form

	Private _questions As List(Of String)
	Private _RadioButtons As List(Of RadioButton)	
	Public Sub New()
		_RadioButtons = New List(Of RadioButton)
		_questions = New List(Of String)
		' Add your questions here
		_questions.Add("Question 1")
		_questions.Add("Question 2")
		_questions.Add("Question 3")
		
		With Me
			.FormBorderStyle = FormBorderStyle.FixedToolWindow
			.StartPosition = FormStartPosition.CenterScreen
			.Width = 300
			.Height = _questions.Count * 20 + 100
			.TopMost = True
			.Font = New Font("Arial",10)
			.Text = "Question Form"
			.ShowInTaskbar = False
		End With
		Dim i = 0
		For Each question As String In _questions
			AddRadioButton(question, i * 20)
			i = i + 1
		Next
		Dim oButton1 As New Button()
		With oButton1			
			.Text = "Ok"
			.Top = Me.Height - 75
			.Left = Me.Width - 130
			.Width = 100
			.Height = 25
			.Enabled = True
			.AutoSize = False
		End With
		Me.Controls.Add(oButton1)
		AddHandler oButton1.Click, AddressOf oButton1_Click		
	End Sub
	
	Private Sub AddRadioButton(Text, i)
		Dim oRadioButton As New RadioButton()
		With oRadioButton
			.Text = Text
			.Top =  10 + i
			.Left = 10
			.AutoSize = True			
		End With
		Me.Controls.Add(oRadioButton)	
		_RadioButtons.Add(oRadioButton)
	End Sub	
  
	Private Sub oButton1_Click(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs)
	
		For Each RadioButton As RadioButton In _RadioButtons
			MsgBox(RadioButton.Text & " = " & RadioButton.checked, , "iLogic")
		Next
		
		' Your code for can go here....		
		
		Me.Close()
	End Sub
End Class


Public Class RunMyForm
	Private Sub Main
		Dim oMyForm As New WinForm
		oMyForm.Show
	End Sub
End Class

 

 

 

EESignature

Message 6 of 6

SharkDesign
Mentor
Mentor

Love coding.

You want 2 buttons? Here's a line of code.

You want 3? Well that's 77 lines now 😂

 

Thanks for everyone's help, need to work out how to integrate this now. 

 

  Inventor Certified Professional