📘 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.

📜 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.
🧰 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
🖥️ 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:
- Pointer
- Button
- Label
- TextBox
- ListView
⇨ Tool Bar: The Toolbar, present below the menu bar, contains frequently used task options like:
- Navigate Backwards
- New Project
- Open File
- Save
- 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.
🔄 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
- Label – Displays text.
- TextBox – Accepts input from user.
- Button – Performs an action on click.
- 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- Click the Toolbox tab to open tools.
- Select a control (e.g., TextBox).
- Click and drag on the form to place it.
- Or double-click the control name to place it automatically.
- Move: Drag the control when cursor changes to move pointer.
- Resize: Drag the edges when resize arrows appear.
🔧 Changing Properties of a Control
In Design Mode:- Select the control.
- Use the Properties window to set attributes like Font, Text, MaxLength, etc.
- Double-click the control to open the Code Editor.
- Use the syntax:
ControlName.Property = Value
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)
- Value: Stores the return value of the MsgBox.
- Message: Message to be displayed (max 1024 characters).
- Style value: Specifies button style (e.g., OK, YesNo, etc.).
- 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)
- Value: Stores the value entered by the user.
- Message: Prompt to the user (required).
- Title: Title of the InputBox window.
- Default_text: Optional text already shown in the box.
💾 Saving a Visual Basic Application
- After working on your project, go to File → Save or Save All.
- You can also use:
- Ctrl + S → Save current file
- Ctrl + Shift + S → Save All files in the project
⟹ The Visual Basic file is saved with extension: .vb
⟹ The project file is saved with extension: .sln
📂 Opening an Existing VB Project
- Click File → Open Project or press
Ctrl + O
. - The "Open Project" dialog box appears.
- Locate and select your saved project file, then click Open.
No comments:
Post a Comment