0% found this document useful (0 votes)
17 views8 pages

Basics Intro To Windows Forms

This document provides an introduction to VB.NET and Windows Forms, covering project structure, common controls, and event-driven programming. It includes examples of declaring variables and handling user input through controls like TextBox and Button. Additionally, it outlines an activity to create a simple program that adds two numbers and displays the result.

Uploaded by

mlbinda6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views8 pages

Basics Intro To Windows Forms

This document provides an introduction to VB.NET and Windows Forms, covering project structure, common controls, and event-driven programming. It includes examples of declaring variables and handling user input through controls like TextBox and Button. Additionally, it outlines an activity to create a simple program that adds two numbers and displays the result.

Uploaded by

mlbinda6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

VB.

NET Basics + Intro to


Windows Forms
Learning Objectives
• Understand the structure of a Windows Forms project
• Learn how to add and use controls (Button, Label, TextBox)
• Understand event-driven programming (Button.Click)
• Apply basic variables and simple logic in a form
Windows Forms Project Structure
• Solution Explorer shows:
– Form1.vb – Your main form
– Form1.Designer.vb – Auto-generated UI code
– Program.vb / ApplicationEvents.vb – Entry point
• Forms are graphical windows where users interact with your
program
Common Controls

• Label – Displays text


• TextBox – Accepts user input
• Button – Performs actions on click
• PictureBox – Displays images
• DataGridView – Displays tables/lists
Event-Driven Programming
• Your program reacts to user actions
• Example: Button Click, Text Change, Form Load

Private Sub Button1_Click(sender As Object, e As EventArgs)


Handles Button1.Click
MessageBox.Show("Button clicked!")
End Sub
Declaring Variables in Forms
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Dim name As String = TextBox1.Text
Dim age As Integer = CInt(TextBox2.Text)
MessageBox.Show("Hello " & name & "! Next year you will be "
& (age + 1))
End Sub

• Dim – Declare variable


• TextBox.Text – Reads user input
• MessageBox.Show() – Displays output
Activity
Create a simple program that will add two numbers:
> Create a form with:

1. 2 TextBoxes → txtNumber1, txtNumber2


– For user to enter two numbers
2. 1 Button → btnAdd,
– To perform a math operation (Add)
3. 1 Label → lblResult
– Displays the calculation result
Activity (Answer)
Private Sub btnAdd_Click(sender As Object, e As EventArgs)
Handles btnAdd.Click
Dim num1 As Double = CDbl(txtNumber1.Text)
Dim num2 As Double = CDbl(txtNumber2.Text)
lblResult.Text = "Sum: " & (num1 + num2)
End Sub

You might also like