Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
6 views15 pages

WindowsForms With Variables DataTypes

This document provides an overview of Windows Forms basics using VB.NET, focusing on applying variables, logic, and event-driven programming. It covers the structure of a Windows Forms project, the use of controls, and examples of different data types and their syntax in VB.NET. By the end of the meeting, participants will be able to implement basic programming concepts in a Windows Forms application.

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)
6 views15 pages

WindowsForms With Variables DataTypes

This document provides an overview of Windows Forms basics using VB.NET, focusing on applying variables, logic, and event-driven programming. It covers the structure of a Windows Forms project, the use of controls, and examples of different data types and their syntax in VB.NET. By the end of the meeting, participants will be able to implement basic programming concepts in a Windows Forms application.

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/ 15

Windows Forms Basics + VB.

NET
Fundamentals

Prepared by: EJ Mata


Objectives
By the end of this meeting, you will be able to:
• Apply basic variables and simple logic in a form
• Apply basic VB.NET syntax, variables, and If-Else logic
QUICK RECAP
Windows Forms Project Structure
Solution Explorer shows:
• Form1.vb – Your main form (event handlers and logic)
• Form1.Designer.vb – Auto-generated UI code
• Program.vb / ApplicationEvents.vb – Entry point
Forms are graphical windows where users interact with
your program
Adding and Using Controls
• Drag controls from the Toolbox to the Form
• Common Controls: Label, TextBox, Button
• Change properties (Text, Name, Size) in Properties
Window
• Example:
- Label: lbl_Greeting
- TextBox: txt_Name
- Button: btn_Submit
Event-Driven Programming
• Windows Forms apps respond to events (clicks, key
presses)
• Each control has events you can handle
• Example: Button.Click event
Private Sub btnSubmit_Click(...) Handles btnSubmit.Click
lblGreeting.Text = "Hello, " & txtName.Text
End Sub
Variables in VB.NET
• Variables are containers for storing data
values.
• Declaration Syntax: Dim variableName As
DataType = value
– Example: Dim age As Integer = 25
• Variables can store different data types like
String, Integer, Double, Boolean.
• Use descriptive names for readability.
Data Types in VB.NET
• String – Text values (e.g., "Hello")
• Integer – Whole numbers (e.g., 42)
• Double – Decimal numbers (e.g., 3.14)
• Boolean – True or False values
• Date – Date and time values
Basic VB.NET Syntax
• Variables: Used to store data values
Example: Dim name As String = "John"

• Data Types: String, Integer, Double, Boolean

• Simple If-Else Logic:


If condition Then
' code here
Else
' code here
End If
String Data Type Example
Dim myName As String = "My name is John"
MsgBox(myName)

Dim myName As String = "Alice"


Dim greeting As String = "Hello, " & myName & "! Welcome to the
program."
MsgBox(greeting)
Integer Data Type Example
Dim age As Integer = 25
MsgBox("Your age is " & age)

Dim a As Integer = 6
Dim b As Integer = 7
Dim product As Integer = a * b

MsgBox("The product of " & a & " and " & b & " is " & product)
Double Data Type Example
Dim temperature As Double = 36.6
MsgBox("The body temperature is " & temperature & "°C")

Dim totalMarks As Double = 87


Dim numberOfSubjects As Double = 5
Dim average As Double = totalMarks / numberOfSubjects

MsgBox("The average mark is " & average)


Boolean Data Type Example
Dim isLoggedIn As Boolean = True
MsgBox("Is user logged in? " & isLoggedIn)

Dim isStudent As Boolean = True


If isStudent Then
MessageBox.Show("Welcome, student!")
Else
MessageBox.Show("Welcome, guest!")
End If
Boolean Data Type Example

Dim isRaining As Boolean = False

If isRaining = True Then


MsgBox("Take an umbrella.")
Else
MsgBox("No need for an umbrella.")
End If
Date Data Type Example
Dim today As Date = Date.Now
MessageBox.Show("Today's date is: " & today)

Dim futureDate As Date = Date.Today.AddDays(7)


MessageBox.Show("One week from today: " & futureDate)

You might also like