0% found this document useful (0 votes)
1 views3 pages

? Week 2

This document provides an introduction to Visual Basic (VB), highlighting its features such as a visual interface, event-driven programming, and rapid application development. It also covers the Visual Studio IDE, the structure of a VB program, and key terms related to controls, events, and properties. Additionally, it includes a step-by-step guide for creating a simple 'Hello, World!' application in VB and prompts for comparison and discussion on programming languages.

Uploaded by

dw8126246
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)
1 views3 pages

? Week 2

This document provides an introduction to Visual Basic (VB), highlighting its features such as a visual interface, event-driven programming, and rapid application development. It also covers the Visual Studio IDE, the structure of a VB program, and key terms related to controls, events, and properties. Additionally, it includes a step-by-step guide for creating a simple 'Hello, World!' application in VB and prompts for comparison and discussion on programming languages.

Uploaded by

dw8126246
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

Week 2: Introduction to Visual Basic (VB)

Lecture Theme: Getting Started with Visual Basic – Concepts, Tools, and Structure
Lecture Focus: Exploring the Visual Basic language, Visual Studio environment, and building
a basic application.
Introduction to Visual Basic (VB) Visual Basic is a high-level programming language
developed by Microsoft. It uses a graphical interface that allows developers to design the
program's user interface visually by dragging and dropping elements onto a form.
History and Features of Visual Basic
Visual Basic (VB) was developed by Microsoft in the early 1990s as a programming language
designed to be easy to use for beginners. It is an event-driven and object-based language,
which makes it very accessible for building Windows applications. Here are some key features:
• Visual Interface: Visual Basic uses a graphical user interface (GUI) that allows
developers to design their applications visually, dragging and dropping controls like
buttons, text boxes, and labels.
• Event-Driven: In VB, the flow of the program is driven by user actions (such as clicks,
typing, etc.), making it well-suited for interactive applications.
• Object-Based: Visual Basic focuses on using objects and properties, making it easier
to model real-world concepts (like a car, a bank account, or a customer) in your
programs.
• Simple Syntax: Easy for beginners to read and write
• Rapid Application Development (RAD): Fast creation of functional applications.

Fact: Many government and corporate applications in Nigeria still run on Visual Basic!

Introduction to Visual Studio Integrated Development Environment (IDE)


Visual Studio is the primary IDE for developing Visual Basic applications. It provides various
tools to help you write, compile, and debug your code.
• Solution Explorer: This panel allows you to view all the files in your project, including
forms, code files, and resource files.
• Toolbox: The Toolbox is a collection of controls that you can drag and drop onto your
forms. Controls include buttons, labels, textboxes, and other user interface elements.
• Properties Window: This window lets you modify the properties of selected objects,
such as changing the text of a button or the background color of a form.
• Code Editor: This is where you write and edit the actual code for your program. You
can switch to the code editor by double-clicking any control (like a button) to add
functionality to it.
• Form Designer: Where visual layout is created
Tip: Always rename your controls (e.g., Button1 to btnSubmit) for clarity and maintainability.

Structure of a Visual Basic Program


In Visual Basic, a program is often built around a form, which is the graphical window that
users interact with.
• Form: This is the main window of your application where you place controls like
buttons, labels, textboxes, etc.
• Controls: These are elements on the form, like buttons, textboxes, labels, listboxes,
and menus, which allow users to interact with the application.
• Events: Events are user actions like clicks or keystrokes that trigger specific code to
run.
• Code Blocks: In VB, each function or event handler is written in a code block. A
typical code block looks like this:
• Property: Describes characteristics like name, color, size.
• Method: A block of code that performs a task.

Element Description
Form1 Main form (UI window)
Button1 A control placed on the form
Label1 Another control
Sub A procedure that runs when the button is clicked

Understanding Key Terms in Visual Basic Controls, Events, and Properties


• Form: The visual interface that users interact with.
• Controls: Visual elements on the form. Common ones:
o Label: Displays static text
o TextBox: Allows user input
o Button: Executes actions
o ComboBox: Dropdown list
• Events: Any action performed by the user or system (e.g., click, hover, load).
• Properties: Attributes of controls (e.g., Name, Size, Color, Text).

First Visual Basic Project – Step-by-Step


Objective: Display “Hello, World!” on a label when a button is clicked.
Steps:
1. Open Visual Studio → File → New → Project
2. Choose Windows Forms App (.NET Framework)
3. Name the project: HelloWorldApp
4. Drag a Label and Button from the toolbox
5. Change the Text property of the label to "" (empty)
6. Change the button’s text to "Say Hello"
7. Double-click the button → Code Editor opens
8. Write:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles [Link]
[Link] = "Hello, World!"
End Sub
9. Press F5 to run the project
Best Practice: Use meaningful names for controls. E.g., btnHello, lblMessage.

Class Demonstration
• Create a Windows Form with a Label and Button
• Label should initially be blank
• When the Button is clicked, the Label displays "Hello, World!"
Lab Task:
• Launch Visual Studio and create a new Windows Forms Application.
• Add a Button and a Label from the Toolbox.
• Double-click the Button and write the provided code to change the label text when the
button is clicked.
• Run the application to verify that clicking the button changes the label text to “Hello,
World!”

Assignment Write a 5–6-line paragraph comparing Visual Basic with either Python or Java.
Mention:
• Ease of use
• Programming style (visual vs. code-based)
• Type of applications typically developed

Discussion Prompt
“Is a GUI-based language like Visual Basic better for beginners than a text-based language like
Python? Why or why not?”

You might also like