Recent Post

Tuesday, 5 August 2025

Chapter 5: Programming in Visual Studio | Computer 8th By Pratap Sanjay Sir

Chapter 5: Programming in Visual Studio | Computer 8th By Pratap Sanjay Sir Computer Notes

🖥️Chapter 5: Programming in Visual Studio

Class 8 CBSE Computer | By Pratap Sanjay Sir

Visual Basic - Class 8

📌 1. Creating a Simple Visual Basic Program

  1. Open Visual Studio 2017.
  2. Go to File → New → Project.
  3. Select Windows Forms App (.NET Framework).
  4. Give your project a name and click OK.
  5. Drag and drop controls like Label, TextBox, and Button from the Toolbox.
  6. Double-click the Button to write the code in its click event.
Example:
Private Sub btnClickMe_Click(sender As Object, e As EventArgs) Handles btnClickMe.Click
    MessageBox.Show("Hello, Welcome to VB!")
End Sub

📌 2. Basic Elements of a Visual Basic Program

  1. Namespace: Container for classes.
  2. Class: Defines the structure of the program.
  3. Method: Performs specific tasks (like Button click).
  4. Controls: UI elements like Label, Button, TextBox.
  5. Variables: Store and manage data during execution.

🔹 Declaring and Initializing Variables

Dim name As String = "Sanjay"
Dim age As Integer = 14

🔹 Data Types

  1. Integer: Whole numbers (e.g., 10)
  2. Double: Decimal values (e.g., 10.5)
  3. String: Text (e.g., "Hello")
  4. Boolean: True or False

🔹 Operators

  1. Arithmetic: +, -, *, /, Mod
  2. Relational: =, <>, >, <, >=, <=
  3. Logical: And, Or, Not
  4. String Concatenation: & (used to join text)
Dim message As String = "Hello " & name

📌 3. Control Statements in Visual Basic

🔹 If...Then Statement

If age >= 18 Then
    MessageBox.Show("You are eligible to vote")
End If

🔹 If...Then...Else Statement

If marks >= 33 Then
    MessageBox.Show("Pass")
Else
    MessageBox.Show("Fail")
End If

🔹 Nested If...Then...Else Statement

If marks >= 75 Then
    MessageBox.Show("Distinction")
ElseIf marks >= 60 Then
    MessageBox.Show("First Division")
ElseIf marks >= 33 Then
    MessageBox.Show("Pass")
Else
    MessageBox.Show("Fail")
End If

🔹 Select Case Statement

Select Case grade
    Case "A"
        MessageBox.Show("Excellent")
    Case "B"
        MessageBox.Show("Good")
    Case Else
        MessageBox.Show("Try Harder")
End Select

📌 4. Looping Statements

🔹 For...Next Loop

For i = 1 To 5
    MessageBox.Show("Number: " & i)
Next

🔹 While...End While Loop

Dim i As Integer = 1
While i <= 5
    MessageBox.Show("Count: " & i)
    i += 1
End While

🔹 Do...Loop While

Dim i As Integer = 1
Do
    MessageBox.Show("Running: " & i)
    i += 1
Loop While i <= 5

📌 5. Some Additional Controls

  • CheckBox: Select multiple options
  • RadioButton: Select one option from many
  • ComboBox: Dropdown list
  • ListBox: List with multiple selectable items
  • Timer: Executes code at set intervals

🔹 CheckBox Example

If chkMath.Checked = True Then
    MessageBox.Show("Math is selected")
End If

🔹 RadioButton Example

If rbtnMale.Checked = True Then
    MessageBox.Show("Gender: Male")
End If



Chapter 5: Programming in Visual Studio Que. & Ans.
Click here to access all Questions & Answers
Visit Now ⤴
By Pratap Sanjay Sir
🔔 Subscribe to My Channel

No comments:

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