.Net Technologies MessageBox using Visual basic.pptx
EllenGracePorras
16 views
23 slides
Oct 26, 2024
Slide 1 of 23
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
About This Presentation
.Net Technologies MessageBox using Visual basic
Size: 1.57 MB
Language: en
Added: Oct 26, 2024
Slides: 23 pages
Slide Content
. Net Technologies Instructor: Ellen Grace Porras
2 Writing the Code
3 The messagebox function enables you to display a message box for which you have designated the format and content. You can specify the number and type of buttons on the message box, the message icon (for example, hand, question mark, exclamation point, or asterisk), and the message displayed. The messagebox function
To create a message box using the .NET Framework, you can call the Show() method of the MessageBox class using the following formula: MessageBox.Show (Message) Syntax: MessageBox.Show ( “Hello World” ) 4
A message box has the following parts: 5
A message box has the following parts: 6 Title : This is typically used to display what the message box is about. If you don’t specify anything, it displays the application name – which is Microsoft Excel in this case. Prompt : This is the message that you want to display. You can use this space to write a couple of lines or even display tables/data here. Button(s) : While OK is the default button, you can customize it to show buttons such as Yes/No, Yes/No/Cancel, Retry/Ignore, etc. Close Icon : You can close the message box by clicking on the close icon.
7 MessageBoxButtons MessageBoxButtons.AbortRetryIgnore displays the Abort, Retry, and Ignore buttons MessageBoxButtons.OK displays the OK button MessageBoxButtons.OKCancel displays the OK and Cancel buttons MessageBoxButtons.RetryCancel displays the Retry and Cancel buttons MessageBoxButtons.YesNo displays the Yes and No buttons MessageBoxButtons.YesNoCancel displays the Yes, No, and Cancel
8 A message box icon
9 MessageBoxDefaultButton MessageBoxDefaultButton.Button1 the first message box button is the default button MessageBoxDefaultButton.Button2 the second message box button is the default button MessageBoxDefaultButton.Button3 the third message box button is the default button
MessageBox.Show( “hi" , "Title" , MessageBoxButtons.YesNo, MessageBoxIcon.Question) 10 Example using MessageBox.Show ()
MessageBox.Show ("The Last Name field must not be blank." , "Last name" , MessageBoxButtons.OK , MessageBoxIcon.Exclamation ) 11 Example using MessageBox.Show ()
MessageBox.Show( "A bad database error has occurred." , "UpdateCustomerTable" ,MessageBoxButtons.OK,MessageBoxIcon.Error) 12 Example using MessageBox.Show ()
Dim MyResponse As DialogResult MyResponse = MessageBox.Show ("Are you sure you want to quit?" , "Quit " , MessageBoxButtons.YesNo , MessageBoxIcon.Question ) If MyResponse = DialogResult.Yes Then Application.Exit () ' end the program End If 13 Example using MessageBox.Show ()
Dim MyAnswer As DialogResult MyAnswer = MessageBox.Show(“ Are you a BSIT Student? ",“ Question ", MessageBoxButtons.YesNo,MessageBoxIcon.Question , MessageBoxDefaultButton.Button2) If MyAnswer = DialogResult.Yes Then MessageBox.Show(“ Hello BSIT ”) Else Application.Exit () End If 14 Example using MessageBox.Show ()
Dim MyAnswer As DialogResult MyAnswer = MessageBox.Show(“ Are you a BSIT Student? ",“ Question ", MessageBoxButtons.YesNo,MessageBoxIcon.Question , MessageBoxDefaultButton.Button2) If MyAnswer = DialogResult.Yes Then MessageBox.Show(“ Hello BSIT ”) Else Application.Exit () End If 15 Example using MessageBox.Show ()
Dim MyAnswer As DialogResult MyAnswer = MessageBox.Show(“ Are you a BSIT Student? ",“ Question ", MessageBoxButtons.YesNo,MessageBoxIcon.Question , MessageBoxDefaultButton.Button2) If MyAnswer = DialogResult.Yes Then MessageBox.Show(“ Hello BSIT ”) Else Application.Exit () End If 16 Example using MessageBox.Show ()
Answe r the following on a 1 whole sheet of paper. Use declaration of variables. Write a program that w ill allow you to enter your Age on TextBox1. If Button1 is clicked, display on a MessageBox the prompt “Your Age is “ then your Age. Title is Age, Button is Ok, Icon is Information. 17 Let’s c heck your knowledge
Answer for number 1 Dim Age as Integer Age= TextBox1.Text MessageBox.Show(“Your Age is ” & Age, “Age”, MessageBoxButtons.Ok , MessageBoxIcon.Information ) 18 Let’s c heck your knowledge
Answe r the following on a 1 whole sheet of paper. Use declaration of variables. 2. Write a program that will multiply numbers on TextBox1 and TextBox2, then display the answer on a MessageBox with a prompt “The answer is “ then the answer, Title is Product, Button is Ok, and Icon is Information. 19 Let’s c heck your knowledge
A nswer for number 2 Dim num1, num2, ans As Integer num1 = TextBox1.Text num2 = TextBox2.Text ans = num1 * num2 MessageBox.Show("The answer is " & ans , "Product", MessageBoxButtons.YesNo , MessageBoxIcon.Information ) 20 Let’s c heck your knowledge
Answe r the following on a 1 whole sheet of paper. Use declaration of variables. 3. Write a program that w ill allow you to enter your first name on Textbox1, Last name on TextBox2. If Button1 is clicked, display on a MessageBox the prompt “Are you “ then your Full name with a question mark. Title is Name, Buttons are YesNo , Icon is Question. If DialogResult is Yes, Display on a MessageBox the prompt “Hello there “ then your Full Name, Title is Name, Button is Ok, Icon is Information. 21 Let’s c heck your knowledge
Answe r for number 3 Dim FN, LN, FUllN As String Dim MyName As DialogResult FN = TextBox1.Text LN = TextBox2.Text FUllN = FN & " " & LN MyName = MessageBox.Show("Are you " & FUllN & "?", "Name", MessageBoxButtons.YesNo , MessageBoxIcon.Question ) If MyName = DialogResult.Yes Then MessageBox.Show("Hello there " & FUllN , "Name", MessageBoxButtons.OK ) End If 22 Let’s c heck your knowledge
Thank you Presenter name: Ellen Grace D. Porras Email address: [email protected]