Visual Basic
Visual Basic
net
• Variety of languages
– Visual Basic Projects
– Visual C# Projects
– Visual C++ Projects
– Setup and Deployment Projects
– Visual Studio Solutions
Project Name
Path
• Printing a text
– Consolse.Write(“String”)
– Console.WriteLine(“The text goes here!”)
• Writeline position the text in the beginning of the next line
• VB.net\LaboratoryExercise\PrintingText
• Types of Variables
– Numeric – Store Numbers
• Addition - +
• Subtraction - -
• Multiplication - *
• Division - /
• Division (Integer) \
• Modulus - Mod
• Exponentiation - ^
• \VB.net\LaboratoryExercise\ConsoleCalculator\ConsoleCalC
• VB.net\LaboratoryExercise\StringManipulation\StringManipulation
If studentGrade>=60 then
Console.WriteLine(“Passed”)
End If
• If/then
– Allows a program to make a decision based on the truth or
falsity of some expression
– It is a condition
Sub Main()
Dim lagyu As String
Dim num1 As Integer
Dim num2 As Integer
Console.WriteLine("Enter first number: ")
num1 = Console.ReadLine()
Console.WriteLine("Enter second number: ")
num2 = Console.ReadLine()
If num1 > num2 Then
Console.WriteLine("Number 1 is greater than number 2")
Else
Console.WriteLine("Number 2 is greater than number 3")
End If
End Sub
End Module
• VB.net\LaboratoryExercise\IFCondition\ifCondition
End Module
End Sub
End Module
Sub Main()
Dim a As Integer
Dim var1 As Integer
Dim sum As Integer
a=1
sum = 0
While a <= 10
Console.WriteLine("Enter Number " & a & ":")
var1 = Console.ReadLine()
a += 1
sum = var1 + sum
End While
Console.WriteLine("The sum is " & sum)
End Sub
End Module
Sub Main()
Dim counter As Integer
For counter = 1 To 10
Console.WriteLine(counter)
Next
End Sub
End Module
VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS”
Using Dialog to Display Message
MessageBox.OK
End Module
• Exit Do, Exit While, Exit For statements alter the flow of control by
causing immediate exit from a repetition structure
• True = False
• True = False
End Sub
End Class
End Sub
End Class
• Application.exit
• formName.ActiveForm.Close()
• Passing a value:
– txtEmpNoOut.Text = txtEmpNo.Text
– txtEmpNameOut.Text = txtLastName.Text & " " &
txtFirstName.Text
• Calculator
• Payroll System
• Picture Swapper
• Allows the user to view and select from multiple items in a list
• listOrder.Items.Add(“Item to Add”)
• listOrder.Items.Clear()
tmp = listOrder.GetItemChecked(ctr - 1)
If tmp = True Then
listOrder.Items.RemoveAt(ctr - 1)
End If
• listOrder.Items.RemoveAt(ctr - 1)
• Font Browser
• POS
• System.data
• System.data.OleDb
• System.Data.SqlClient
• System.Data.Dataset
• Dbase Application
• New Connection
– Data Source – Database Connection
– Database File Name – File Name of the database
• Change the Datasource
– Microsoft Access Database File
– Click Ok
– Find the Access File
– Test the connection
• Click OK
• Choose Use SQL Statements
• Insert your SQL
• Click Finish