Recent Post

Thursday, 3 July 2025

Visual Basic - Class 8 CBSE Computer Notes

Visual Basic - Class 8 CBSE Computer Notes | By Pratap Sanjay Sir

📘 Visual Basic - Class 8 CBSE Notes

🔰 Visual Basic

➥ Visual Basic (VB) is a graphical version of the BASIC programming language.

⇨ Unlike BASIC, it is visual and event-driven.

⇨ It is simple and easy to learn.

⇨ Provides a Graphical User Interface (GUI) environment for development.

⇨ It allows you to create Windows-based applications with graphical interfaces.

➱ It is suitable for beginners and school students.

Introduction to VB

📜 History

➥ First released by Microsoft Corporation in 1991 with the help of Alan Cooper.

⇨ Versions released: VB 1.0, 2.0, 3.0, 4.0, 5.0, and 6.0.

⇨ Later shifted to the .NET Framework versions:

⇨ Visual Basic .NET, VB.NET 2003, VB 2005, 2008, 2010, 2012, and 2017

➱ Widely used in schools, colleges, and industries.

⚙️ What is Event-Driven Programming?

➥ Event-driven programming is based on responding to user actions (events).

⇨ Examples: key press, mouse click, form load, etc.

⇨ Each GUI component (button, textbox, etc.) is coded to respond to specific events.

➱ Visual Basic uses independent subprograms for each event.

Event Driven Concept

🧰 Visual Studio IDE

➥ To create a Visual Basic program, download Visual Studio Express for Windows Desktop.

⇨ Supports other languages like Visual C#, C++, and SQL Server.

➱ Download link: Click here

VS 2017 Express

🖥️ Starting Visual Studio Express

➥ Open Start Menu → Select VS Express for Windows Desktop.

⇨ Click on Create New Project.

⇨ Choose Visual Basic from the left panel.

⇨ Select Windows Form App (.NET Framework).

➱ Type project name and location → Click OK.

📂 Components of Visual Studio Window

Title Bar: Shows project name and application.

Menu Bar: Includes File, Edit, View, Project, Debug, etc.

Toolbox: Contains commonly used controls in VB like:

  1. Pointer
  2. Button
  3. Label
  4. TextBox
  5. ListView

Tool Bar: The Toolbar, present below the menu bar, contains frequently used task options like:

  1. Navigate Backwards
  2. New Project
  3. Open File
  4. Save
  5. Save All

Form Window: Design area for GUI elements.

Properties Window: Used to set control properties.

Solution Explorer: Displays all project files.

Code Editor: Used for writing and editing program logic.

Window Components

🔄 Modes of Visual Studio

Design Mode: – Used to design the layout (drag and drop controls).

Run Mode: – Used to test/run the application.

Break/Suspended Mode: – Used to debug code.

📚 Properties, Methods & Events

Properties: – Define control features (Text, Color, Font).

Methods: – Built-in actions (e.g., Show(), Close()).

Events: – Triggered by user actions (Click, Load).

🧮 Common Controls in VB

  1. Label – Displays text.
  2. TextBox – Accepts input from user.
  3. Button – Performs an action on click.
  4. CheckBox, RadioButton, PictureBox, ListBox – Other useful controls.

1. Label Control

Properties: Name, Text, Font, ForeColor, BackColor

Methods: Show, Hide, Focus

Events: Click, DoubleClick

2. TextBox Control

Properties: Name, MaxLength, Font, PasswordChar, Text

Methods: Clear, Copy, Focus, Show, Hide

Events: TextChanged, Click, DoubleClick

3. Button Control

Properties: Name, Text, Font

Methods: Show, Hide, Select

Events: Click, DoubleClick, TextChanged

🛠️ Working with Controls

Inserting Controls in Form
  1. Click the Toolbox tab to open tools.
  2. Select a control (e.g., TextBox).
  3. Click and drag on the form to place it.
  4. Or double-click the control name to place it automatically.
Resizing and Moving Controls
  1. Move: Drag the control when cursor changes to move pointer.
  2. Resize: Drag the edges when resize arrows appear.
Working with Controls

🔧 Changing Properties of a Control

In Design Mode:
  1. Select the control.
  2. Use the Properties window to set attributes like Font, Text, MaxLength, etc.
In Run Mode:
  1. Double-click the control to open the Code Editor.
  2. Use the syntax:
     ControlName.Property = Value
Example:
Change the color of text in a textbox:
Public Class Form1
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
    TextBox1.ForeColor = Color.Red
End Sub
End Class

🧠 Commonly Used Functions

1. MsgBox() Function

Used to display messages to the user in a message box.

Syntax:
 
Value = MsgBox(Message, Style_value, Title)
  
  1. Value: Stores the return value of the MsgBox.
  2. Message: Message to be displayed (max 1024 characters).
  3. Style value: Specifies button style (e.g., OK, YesNo, etc.).
  4. Title: Appears in the title bar of the message box.
2. InputBox() Function

Used to accept input from the user.

Syntax:
 
Value = InputBox(Message, Title, Default_text)
  
  1. Value: Stores the value entered by the user.
  2. Message: Prompt to the user (required).
  3. Title: Title of the InputBox window.
  4. Default_text: Optional text already shown in the box.

💾 Saving a Visual Basic Application

  1. After working on your project, go to File → Save or Save All.
  2. You can also use:
    • Ctrl + S → Save current file
    • Ctrl + Shift + S → Save All files in the project
  3. ⟹ The Visual Basic file is saved with extension: .vb
    ⟹ The project file is saved with extension: .sln

📂 Opening an Existing VB Project

  1. Click File → Open Project or press Ctrl + O.
  2. The "Open Project" dialog box appears.
  3. Locate and select your saved project file, then click Open.



Visual Basic Q&A
Click here to access all Questions & Answers
Visit Now ⤴

🔔 Subscribe to My Channel

No comments:

"कोशिश करो तो सब कुछ हो सकता है, न करो तो कुछ नहीं हो सकता।"