InputRadioBox() in API

InputRadioBox() in API

ngdnam88
Advocate Advocate
628 Views
8 Replies
Message 1 of 9

InputRadioBox() in API

ngdnam88
Advocate
Advocate

Dears,

I'm try to using InputRadioBox() with this Syntax:

Dim oOption As Boolean = InputRadioBox("Options", "Option 1", "Option 2", True, Title:="Choose the Option?")

 but I got an error. It's working in iLogic rule but with API is not

ngnam1988_0-1671102159321.png

So please help me or give me an idea. I'm using VS2022 with Inventor 2018.

Thanks!

0 Likes
629 Views
8 Replies
Replies (8)
Message 2 of 9

Daan_M
Collaborator
Collaborator

 

Public Class RadioBtn  
    Private Sub RadioBtn_Load(sender As Object, e As EventArgs) Handles MyBase.Load  
        Me.Text = "RadioBox" 
        Label1.Text = "Choose your option"  
        RadioButton1.Text = "Option 1" 
        RadioButton2.Text = "Option 2"    
        Button1.Text = "Submit"   
        Button2.Text = "Exit"  
    End Sub  

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click  
        End 
    End Sub 

End Class  

 

Message 3 of 9

Dev_rim
Advocate
Advocate

Hi There,

There is 3 option that you can use for create messageboxes.

1. CommandManager.PromptMessage()

2. MsgBox.Show      ====> (This one is a VB function)

3. You can create your own dialog.

 

For the 1st one:

 

Dim cmdMgr As CommandManager = application.CommandManager
answercmdMgr.PromptMessage("MESSAGE", BUTTONS, "TITLE")

 

So BUTTONS is some LONG variable that represents button types. Alsi this prompt message function will return an answer as LONG. 

If you look at this site:

https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/msgbox-constants

You can find out what is the values and names of Buttons and which button returns which value.

 

The second one is more common. Its basically creates a message box and returns the answer:

MsgBox (prompt, [ buttons, ] [ title, ] [ helpfilecontext ])

You can also see the explanation for it here:

https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/msgbox-function

Here is one:

 

Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Do you want to continue ?"    ' Define message.
Style = vbYesNo Or vbCritical Or vbDefaultButton2    ' Define buttons.
Title = "MsgBox Demonstration"    ' Define title.
Help = "DEMO.HLP"    ' Define Help file.
Ctxt = 1000    ' Define topic context. 
        ' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then    ' User chose Yes.
    MyString = "Yes"    ' Perform some action.
Else    ' User chose No.
    MyString = "No"    ' Perform some action.
End If

 

 

And the last option you have... You can create a form and use ShowDialog().

This is probably most complicated one so you can read this article.

https://www.javatpoint.com/vb-net-dialog-box

 

 

But all of them basically works same. 

 

Best Regards

Devrim

If my answer is solved your problem, please mark it as Solution

Freundliche Grüße / Kind Regards
Message 4 of 9

ngdnam88
Advocate
Advocate

Thanks @Daan_M 
I tried your code but VS return some error. Can you help me fix it?

ngnam1988_0-1671165127031.png

 

0 Likes
Message 5 of 9

ngdnam88
Advocate
Advocate

Thanks @Dev_rim 
Maybe I'll try to do MsgBox() / PromptMessage() instead for InputRadioBox(). The 1st way I got the good result, 

ngnam1988_0-1671165228159.png

Is InputRadioBox() not available in VS?

ngnam1988_1-1671165399235.png

Message 6 of 9

ngdnam88
Advocate
Advocate

Hi @Daan_M 

Could you please help me how to pass the value from Windows Forms as my picture?

ngnam1988_0-1672133384759.png

I just learnt to created the Windows Forms,

Thanks!

0 Likes
Message 7 of 9

Dev_rim
Advocate
Advocate

Hi, 

You need to show the Form as Dialog. So you need to use ShowDialog() instead of Show(). And then You can get the DialogResult object.

Private Sub ShowOptionsForm()
    Dim options = New frmOptions

    ' Did the user click Save?
    If options.ShowDialog() = Windows.Forms.DialogResult.OK Then
        ' Yes, so grab the values you want from the dialog here
        Dim textBoxValue As String = options.txtMyTextValue.Text
    End If
End Sub

You can add the dialog result for the checkboxes. In this code below, some form button programmed to return OK value when its clicked.

Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
    ' Set the result to pass back to the form that called this dialog
    Me.DialogResult = Windows.Forms.DialogResult.OK
End Sub

 

I hope this will helps.

Devrim.

If my answer is solved your problem, please mark it as Solution

Freundliche Grüße / Kind Regards
0 Likes
Message 8 of 9

WCrihfield
Mentor
Mentor

Hi guys.  Just dropping a little data in here.  Both the InputListBox and the InputRadioBox are created by Autodesk, within the Autodesk.iLogic.Runtime Namespace, within its RunDialogs module, in their iLogic add-in.  The others, like MessageBox, MsgBox, InputBox, and such are designed by the VB.NET code platform, outside of Autodesk's control (some under System.Windows.Forms hierarchy, and others under Microsoft.VisualBasic.Interactions hierarchy).  With this in mind, I wander if it may be possible to include a reference to those Autodesk source files, then create a variable to represent something from from that reference that could be used within Visual Studio code to take advantage of their source code.  Just throwing that idea out there, in case it might lead to further development.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 9 of 9

WCrihfield
Mentor
Mentor

Just found another useful clue a developer might be able to use in this situation.  Not only is there a Autodesk.iLogic.Runtime.dll file that you can reference, right in the "C:\Program Files\Autodesk\Inventor 2022\Bin" folder, but within an iLogic rule editor, you can type in the following:

Dim oGRBB As New Autodesk.iLogic.Runtime.GenericRadioButtonBox
oGRBB.

...and when you delete the "." after the oGRBB on the second line, then add it back, you will see a super long scrolling list of its properties, methods, & events.  Very similar to the properties of a regular Windows.Forms.Form Type object.  This looks like a good stepping stone for possibly taking advantage of Autodesk's source code for the InputRadioBox used in an iLogic rule, from a code in Visual Studio, after you have added that reference in there.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes