Forms
  • Window Forms and examples in Visual Basic .Net are the basic objects used to develop an application.
  • It also contains the coding as well as the controls embedded in it to create the user interface.
  • Forms are created by default when a Project is created in VB .Net with a default name Form1.
  • Every form has its Properties, Methods, and Events.
  • The common form properties are name, text, caption, color, etc., and are changed as required.
  • There are multiple forms associated with a typical Project.
SDI & MDI
  • Single Document Interface (SDI):
    • SDI is an application software Interface/GUI tool that opens a single document each time in its primary window after prompting to close the previously opened one.
    • SDI contains/controls one window only at a time. Thus, SDI supports only one interface /application at a time and hence slow processing.
    • Here, each window has its menu, toolbar, and entry in the taskbar. Therefore, an SDI is not constrained to a parent window. This makes it easier for the user to view/edit the contents of the windows.
    • Notepad & MS-Paint applications are examples of common SDI applications.
  • Multiple Document Interface (MDI):
    • MDI is an application software Interface/GUI tool that opens more than one document each time in its primary window without prompting to close the previously opened one.
    • MDI contains/controls multiple documents at a time appearing as a child window. Thus, MDI supports/handles many applications at a time according to the user’s requirement and hence fast processing.
    • MDI may switch from one or other documents as needed.
    • The MDI has a parent window and may contain any number of child windows. The child windows usually share various parts of the parent window’s interface, including the menu bar, toolbar, and status bar.
    •  Microsoft Visual Studio, MS Word, MS Excel, etc are MDI applications.

—————————————————  OR  ———————————————————–

Example : A Window Forms and Examples in VB .Net 2013 to display a Static Simple Message on pressing a Button.
Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        MsgBox("Welcome New Year 2023")
    End Sub
End Class

NB: Open a VB 2013 Window application first - Create a new project(as WindowApplication1) - Now, Create a new Form(as Form1) - Draw a button on to the Form(as button1) - Double click on the button - Now write the code as above - Run the code by pressing F5/start button from the standard toolbar - Output appears.
Example : Create a Window Form Application in VB .Net 2013 to display a Static Simple Message in a Text Box on pressing a Button.
Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        TextBox1.Text = "Welcome New Year 2023"
    End Sub
End Class
Example : Create a Window Form Application in VB .Net 2013 to display the Addition result of two values in a Text Box on pressing a Button.
Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
    End Sub
End Class
Example : Create a Window Form Application in VB .Net 2013 to display all the numbers from 1 to 10 using For loop in a Text Box on pressing a Button.
Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim i As Integer
        For i = 1 To 10
            TextBox1.Text = TextBox1.Text & " " & i
        Next
    End Sub
End Class
Example : Create a Window Form Application in VB .Net 2013 to display all the numbers from 100 to 10 with interval of 5 using For loop in a Text Box on pressing a Button.
Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim i As Integer
        For i = 100 To 10 Step -5
            TextBox1.Text = TextBox1.Text & " " & i
        Next
    End Sub
End Class
Example : Create a Window Form Application in VB .Net 2013 to display all the numbers between two numbers given by the user at run time(dynamic value) using For loop in a Text Box on pressing a Button.
Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim i As Integer
        For i = TextBox1.Text To TextBox2.Text Step 1
            TextBox3.Text = TextBox3.Text & " " & i
        Next
    End Sub
End Class
Example : Create a Window Form Application in VB .Net 2013 to display the Reverse of the accepted numbers from user at run time(dynamic value) using While loop in a Text Box on pressing a Button.
Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim x As Integer = Val(TextBox1.Text)
        Dim y, result As Integer
        While x > 0
            y = x Mod 10
            result = result * 10 + y
            x = x \ 10
        End While
        TextBox2.Text = result
    End Sub
End Class
Example : Create a Window Form Application in VB .Net 2013 to display the Reverse of the accepted numbers from user at run time(dynamic value) through User Defined Function using While loop in a Text Box on pressing a Button.
Public Class Form1
    Public Function Reverse(x2 As Integer)
        Dim y, result As Integer
        While x2 > 0
            y = x2 Mod 10
            result = result * 10 + y
            x2 = x2 \ 10
        End While
        Reverse = result
    End Function

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim x1 As Integer = Val(TextBox1.Text)
        TextBox2.Text = Reverse(x1)
    End Sub
End Class

Loading


0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.