Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Tuesday, June 16, 2020 10:06 AM
Hi Good People
How is code written for a MsgBox or MessageBox in Visual Basic 2019, I am having trouble with the code I Use to use for a MsgBox.
Please can any of you good people show me the best way to write this code in Visual Basic 2019
Kind Regards
Gary
Dim Result As DialogResult
Result = MsgBox("Have You Forgotten Something", vbYesNo, MsgBoxStyle.Question, "Parts")
If Result = DialogResult.No Then
'Do Something
ElseIf Result = DialogResult.Yes Then
'Do Something Else
End If
Gary Simpson
Tuesday, June 16, 2020 10:08 AM ✅Answered | 1 vote
Tuesday, June 16, 2020 10:36 AM ✅Answered | 1 vote
I have had a look at the Link you supplied But it is all in C#. I am Looking VB.net. And I have searched MessageBox Class in VB.net But I have not found any in the VB Language
You can choose the language at Top-Right
Tuesday, June 16, 2020 10:50 AM ✅Answered | 1 vote
Hi Castorix31
Thank you for getting back to me.
I have had a look at the Link you supplied But it is all in C#. I am Looking VB.net. And I have searched MessageBox Class in VB.net But I have not found any in the VB Language
Regards
Gary
Gary Simpson
Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
NuGet BaseConnectionLibrary for database connections.
Tuesday, June 16, 2020 10:30 AM
Hi Castorix31
Thank you for getting back to me.
I have had a look at the Link you supplied But it is all in C#. I am Looking VB.net. And I have searched MessageBox Class in VB.net But I have not found any in the VB Language
Regards
Gary
Gary Simpson
Tuesday, June 16, 2020 10:48 AM | 1 vote
Hello,
Here are several wrappers for MessageBox which I placed under My namespace. The idea is to keep lengthy code out of main code and rather than check for DialogResult in your code check for true or false.
https://gist.github.com/karenpayneoregon/0279cd28d1b9bf4cae1b6c5682f03f08
Usage
If My.Dialogs.Question("Have you forgotten something", "Parts") Then
' TODO
Else
' TODO
End If
Note as coded the default button is No, not yes. You can change it.
Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
NuGet BaseConnectionLibrary for database connections.
Tuesday, June 16, 2020 11:23 AM | 1 vote
A big Thank you to you good people.
This is the code I have ended up with.
ElseIf txtPartPrice1.Text = "" AndAlso CBool(GetDec("0.00")) Then
' Initializes variables to pass to the MessageBox.Show method.
Dim Message As String = "Have you forgotten to enter Price of Parts?"
Dim Caption As String = "No Parts have been Added"
Dim Buttons As MessageBoxButtons = MessageBoxButtons.YesNo
Dim Result As DialogResult
'Displays the MessageBox
Result = MessageBox.Show(Message, Caption, Buttons)
' Gets the result of the MessageBox display.
If Result = System.Windows.Forms.DialogResult.Yes Then
' Go to TxtPartPrice1
txtPartPrice1.Focus()
ElseIf Result = System.Windows.Forms.DialogResult.No Then
'Insert into Database
InsertJob()
Thank you very Much
Best Regards
Gary
Gary Simpson