AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VB.Net: messagebox with Yes/No Buttons?

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Peter2_1
5772 Views, 4 Replies

VB.Net: messagebox with Yes/No Buttons?

Peter2_1
Collaborator
Collaborator

Oracle, Industry Model

-------------------

For "standard" VB.net, I found this code to create a "Yes/No-Messagebox" and folowing If - else - condition:

 

Dim rslt As New System.Windows.Forms.DialogResult 
rslt = MessageBox.Show("Text", "Titel", MessageBoxButtons.YesNo)
If rslt = Windows.Forms.DialogResult.Yes Then
'YES pressed
Else
'NO pressed
End If

How has it to be modified to run in VB.Script in forms?

AutoCAD Map 3D 2023 German / Oracle
0 Likes

VB.Net: messagebox with Yes/No Buttons?

Oracle, Industry Model

-------------------

For "standard" VB.net, I found this code to create a "Yes/No-Messagebox" and folowing If - else - condition:

 

Dim rslt As New System.Windows.Forms.DialogResult 
rslt = MessageBox.Show("Text", "Titel", MessageBoxButtons.YesNo)
If rslt = Windows.Forms.DialogResult.Yes Then
'YES pressed
Else
'NO pressed
End If

How has it to be modified to run in VB.Script in forms?

AutoCAD Map 3D 2023 German / Oracle
4 REPLIES 4
Message 2 of 5
norman.yuan
in reply to: Peter2_1

norman.yuan
Mentor
Mentor

@Peter2_1 wrote:

Oracle, Industry Model

-------------------

For "standard" VB.net, I found this code to create a "Yes/No-Messagebox" and folowing If - else - condition:

 

Dim rslt As New System.Windows.Forms.DialogResult 
rslt = MessageBox.Show("Text", "Titel", MessageBoxButtons.YesNo)
If rslt = Windows.Forms.DialogResult.Yes Then
'YES pressed
Else
'NO pressed
End If

How has it to be modified to run in VB.Script in forms?


By saying "VB.Script", since you are asking question on AutoCAD(Map) programming, I assume you mean AutoCAD VBA.

 

No, you cannot use VB.NET code/syntax with AutoCAD VBA. But with VBA built-in MsgBox (applies to all VBA, AutoCAD, Excel, Word...), you can do basically the same thing. See code sample below:

 

Public Sub test()
    Dim answer As VbMsgBoxStyle
    answer = MsgBox("Please answer this question:" & vbCrLf & vbCrLf & _
        "1+1=5" & vbCrLf & vbCrLf & "Yes or No?", vbYesNo + vbDefaultButton2)
    If answer = vbNo Then
        MsgBox "Your answer is correct.", vbOKOnly
    Else
        MsgBox "Your answer is wrong!", vbOKOnly
    End If
End Sub

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes


@Peter2_1 wrote:

Oracle, Industry Model

-------------------

For "standard" VB.net, I found this code to create a "Yes/No-Messagebox" and folowing If - else - condition:

 

Dim rslt As New System.Windows.Forms.DialogResult 
rslt = MessageBox.Show("Text", "Titel", MessageBoxButtons.YesNo)
If rslt = Windows.Forms.DialogResult.Yes Then
'YES pressed
Else
'NO pressed
End If

How has it to be modified to run in VB.Script in forms?


By saying "VB.Script", since you are asking question on AutoCAD(Map) programming, I assume you mean AutoCAD VBA.

 

No, you cannot use VB.NET code/syntax with AutoCAD VBA. But with VBA built-in MsgBox (applies to all VBA, AutoCAD, Excel, Word...), you can do basically the same thing. See code sample below:

 

Public Sub test()
    Dim answer As VbMsgBoxStyle
    answer = MsgBox("Please answer this question:" & vbCrLf & vbCrLf & _
        "1+1=5" & vbCrLf & vbCrLf & "Yes or No?", vbYesNo + vbDefaultButton2)
    If answer = vbNo Then
        MsgBox "Your answer is correct.", vbOKOnly
    Else
        MsgBox "Your answer is wrong!", vbOKOnly
    End If
End Sub

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 5
Peter2_1
in reply to: norman.yuan

Peter2_1
Collaborator
Collaborator

Thanks Norman,

 

but I don't mean VBA.

I mean this

Use the Script Programmable (ScriptButton) control to execute small scripts. Its function is similar to the Formula TextBox control. You can use VB .NET and the API in the scripts. 

taken from here

http://help.autodesk.com/view/MAP/2018/ENU/?guid=GUID-CD132535-11CC-4BB4-80C8-12211DD26843

and other linked pages ...

AutoCAD Map 3D 2023 German / Oracle
0 Likes

Thanks Norman,

 

but I don't mean VBA.

I mean this

Use the Script Programmable (ScriptButton) control to execute small scripts. Its function is similar to the Formula TextBox control. You can use VB .NET and the API in the scripts. 

taken from here

http://help.autodesk.com/view/MAP/2018/ENU/?guid=GUID-CD132535-11CC-4BB4-80C8-12211DD26843

and other linked pages ...

AutoCAD Map 3D 2023 German / Oracle
Message 4 of 5
norman.yuan
in reply to: Peter2_1

norman.yuan
Mentor
Mentor

Ah, it is IM in Map3D, which I never used in real production. Since IM is exposed its API with .NET and its Form Designer documentation you referred to says VB.NET is used as the scripting language entered via the costum Form Control (ScriptButton), my guess would that .NET's System.Windows.Forms.MessageBox can be used. However, VB.NET still has the old MsgBox "inherited" from classical VB5/6/VBA directly available and can be used in the exactly the same way as my code shows. You can try out with both. But in most cases, I'd be against popping up message during scripting process. If some process is complicated enough to be interrupted and waiting for user interaction, it might be better to processed separately in a customized execution, rather than simple scripting.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes

Ah, it is IM in Map3D, which I never used in real production. Since IM is exposed its API with .NET and its Form Designer documentation you referred to says VB.NET is used as the scripting language entered via the costum Form Control (ScriptButton), my guess would that .NET's System.Windows.Forms.MessageBox can be used. However, VB.NET still has the old MsgBox "inherited" from classical VB5/6/VBA directly available and can be used in the exactly the same way as my code shows. You can try out with both. But in most cases, I'd be against popping up message during scripting process. If some process is complicated enough to be interrupted and waiting for user interaction, it might be better to processed separately in a customized execution, rather than simple scripting.

 

Norman Yuan

Drive CAD With Code

EESignature

Message 5 of 5
Peter2_1
in reply to: norman.yuan

Peter2_1
Collaborator
Collaborator
Accepted solution

Thanks, with small modifications I could make a little progress. This code is OK

 
 

vb_script_messagebox.PNG

 

But nevertheless there is a difference between my first vb.net example and your VBa example (brackets, codes, options, ...). This is the information that I'm hoping to find - somewhere, somehow, sometimes ...

 

Edit: Maybe here are some informations:

https://de.wikibooks.org/wiki/Visual_Basic_Script_(VBS):_Wichtige_Objekte_und_Funktionen#Wichtige_Fu...

 

AutoCAD Map 3D 2023 German / Oracle
0 Likes

Thanks, with small modifications I could make a little progress. This code is OK

 
 

vb_script_messagebox.PNG

 

But nevertheless there is a difference between my first vb.net example and your VBa example (brackets, codes, options, ...). This is the information that I'm hoping to find - somewhere, somehow, sometimes ...

 

Edit: Maybe here are some informations:

https://de.wikibooks.org/wiki/Visual_Basic_Script_(VBS):_Wichtige_Objekte_und_Funktionen#Wichtige_Fu...

 

AutoCAD Map 3D 2023 German / Oracle

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report