VB Msgbox Input Box Mdi-1
VB Msgbox Input Box Mdi-1
Example1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim testmsg As Integer
testmsg = MsgBox("Click to test", 1, "Test message")
If testmsg = 1 Then
MessageBox.Show("You have clicked the OK button")
Else
MessageBox.Show("You have clicked the Cancel button")
End If
End Sub
To make the message box looks more sophisticated, you can add an
icon besides the message. There are four types of icons available in
VB2012 as shown in Table 3
Table 3 Types of Icons
Example 2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim testMsg As Integer
testMsg = MsgBox("Click to Test", vbYesNoCancel +
vbExclamation, "Test Message")
If testMsg = 6 Then
MessageBox.Show("You have clicked the yes button")
ElseIf testMsg = 7 Then
MessageBox.Show("You have clicked the NO button")
Else
MessageBox.Show("You have clicked the Cancel button")
End If
End Sub
The first argument, Prompt, will display the message
The MDI applications act as the parent and child relationship in a form. A parent form is
a container that contains child forms, while child forms can be multiple to display
different modules in a parent form.
1. MidParent: The MidParent property is used to set a parent form to a child form.
2. ActiveMdiChild: The ActiveMdiChild property is used to get the reference of the
current child form.
3. IsMdiContainer: The IsMdiContainer property set a Boolean value to True that
represents the creation of a form as an MDI form.
4. LayoutMdi(): The LayoutMdi() method is used to arrange the child forms in the
parent or main form.
5. Controls: It is used to get the reference of control from the child form.
Let's create a program to display the multiple windows in the VB.NET Windows Forms.
Step 1: First, we have to open the Windows form and create the Menu bar with the use
of MenuStrip control, as shown below.
Step 2: After creating the Menu, add the Subitems into the Menu bar, as shown below.
In the above image, we have defined two Subitems, First is the Feedback Form, and the
Second is VB.NET.
Step 3: In the third step, we will create two Forms: The Child Form of the Main
Form or Parent Form.
Here, we have created the first Child Form with the name Form2.
Form2.vb
Form3.vb
Step 4: Now we write the programming code for the Main or Parent Form, and here is
the code for our Main Form.
MDI_form.vb
IsMdiContainer = True 'Set the Boolean value to true to create the form as an MDI
form.
Me.Text = "lnmipatna.ac.in" 'set the title of the form
PictureBox1.Image = Image.FromFile("C:\Logo.png")
PictureBox1.Height = 550
PictureBox1.Width = 750
End Sub
Private Sub FeedbackFormToolStripMenuItem_Click(sender As Object, e As EventArgs)
Handles FeedbackFormToolStripMenuItem.Click
PictureBox1.Visible = False
Dim fm2 As New Form2
fm2.MdiParent = Me 'define the parent of form3, where Me -same form
fm2.Show() 'Display the form3
End Sub
Private Sub VBNETToolStripMenuItem_Click(sender As Object, e As EventArgs) Handle
s VBNETToolStripMenuItem.Click
PictureBox1.Visible = False
Dim fm3 As New Form3
fm3.MdiParent = Me 'define the parent of form3, where Me represent the same for
m
fm3.Show() 'Display the form3
End Sub
End Class
After that, click on the Menu button, it shows two sub-items of the Menu as Feedback
Form and VB.NET. We have clicked on the Feedback Form that displays the following
form on the window.
When we click on the Menu item, it shows the following image on the screen.