Microsoft Word DJAP4 BCA
Microsoft Word DJAP4 BCA
Microsoft Word DJAP4 BCA
BCA
1
DIRECTORATE OF DISTANCE & CONTINUING EDUCATION
MANONMANIAM SUNDARANAR UNIVERSITY
Reaccredited with ‘A’ Grade (CGPA 3.13 out of 4.0) by NAAC (3rd Cycle)
TIRUNELVELI – 627 012, Tamilnadu, India
________________.
2
Visual Basic (DJAP4 – Practical IV )
CONTENTS
2. String Concatenation 05
3. Vowel or Not 06
4. String Conversion 07
5. Simple Calculator 08
6. Online Examination 12
3
Excercise Number - 1: Print the sentence
Aim:
To write a program to print the sentence "Write First program in Visual basic"
Algorithm:
Source Code:
Module Module1
Sub Main()
Dim str As String
str = "Write First program in Visual basic"
Console.WriteLine(str)
Console.ReadLine()
End Sub
End Module
Output:
Result:
Thus the program was executed and its output was verified.
4
Excercise Number - 2: String Concatenation
Aim:
Algorithm:
Source Code:
Module Module1
Sub Main()
Dim str1, str2, str3 As String
str1 = "Visual"
str2 = "Basic"
str3 = "Program"
Console.WriteLine(str1 + " " + str2 + " " + str3)
Console.ReadLine()
End Sub
End Module
Output:
Visual basic program
Result:
Thus the program was executed and its output was verified.
5
Excercise Number - 3: Vowel or not
Aim:
Algorithm:
1. Start the application and create and design a form with needed buttons
2. Click the button to write the program in editor page
3. To declare the variable as string
4. To create textbox and assign the textbox values as variable
5. If the textbox values as vowel then the message box displays “The Given String is
vowel”
6. Otherwise the messagebox displays “The Given String is not vowel”
7. Deploy and run the program
Source Code:
Output:
Result:
Thus the program was executed and its output was verified.
6
Excercise Number - 4: String Conversion
Aim:
To write a program to accept character for console and check the case of the character.
Algorithm:
Source Code:
Output:
Result:
Thus the program was executed and its output was verified.
7
Excercise Number - 5: Simple Calculator
Aim:
Algorithm:
1. Start the application
2. Open a new file and design the form with needed such controls as labelbox,
textbox,button.
3. Click the button to write the program in editor page
4. Click the +,-,*,/ operator to prefer their respective operations
5. Use if else condition to do all the operations of arithmetic calculations
6. Deploy and run the program
Source code:
Public Class Form1
Dim frstnum As Decimal
Dim scndnum As Decimal
Dim operations As Integer
Dim operator_selector As Boolean = False
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "1"
Else
TextBox1.Text = "1"
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "2"
Else
TextBox1.Text = "2"
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "3"
Else
TextBox1.Text = "3"
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
8
If TextBox1.Text <> "0" Then
TextBox1.Text += "4"
Else
TextBox1.Text = "4"
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "5"
Else
TextBox1.Text = "5"
End If
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button6.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "6"
Else
TextBox1.Text = "6"
End If
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button7.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "7"
Else
TextBox1.Text = "7"
End If
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button8.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "8"
Else
TextBox1.Text = "8"
End If
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button9.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "9"
Else
TextBox1.Text = "9"
End If
End Sub
9
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button10.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "0"
End If
End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button11.Click
frstnum = TextBox1.Text
TextBox1.Text = "0"
operator_selector = True
operations = 1 '=+
End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button12.Click
frstnum = TextBox1.Text
TextBox1.Text = "0"
operator_selector = True
operations = 2 '=-
End Sub
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button13.Click
frstnum = TextBox1.Text
TextBox1.Text = "0"
operator_selector = True
operations = 3 '=*
End Sub
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button14.Click
frstnum = TextBox1.Text
TextBox1.Text = "0"
operator_selector = True
operations = 4 '=/
End Sub
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button16.Click
If Not (TextBox1.Text.Contains(".")) Then
TextBox1.Text += "."
End If
End Sub
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button15.Click
TextBox1.Text = "0"
End Sub
Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button17.Click
10
If operator_selector = True Then
scndnum = TextBox1.Text
If operations = 1 Then
TextBox1.Text = frstnum + scndnum
ElseIf operations = 2 Then
TextBox1.Text = frstnum - scndnum
ElseIf operations = 3 Then
TextBox1.Text = frstnum * scndnum
ElseIfscndnum = 0 Then
TextBox1.Text = "Error!"
Else
TextBox1.Text = frstnum / scndnum
End If
operator_selector = False
End If
End Sub
End Class
Output:
Result:
Thus the program was executed and its output was verified.
11
Excercise Number - 6: Online Examination
Aim:
Algorithm:
Source Code:
12
End If
End Sub
End ClassPublic Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Label3.Text = 20
Timer1.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Label3.Visible = False
Dim total As Integer
total = 0
If RadioButton1.Checked = True Then
total += 1
End If
If RadioButton3.Checked = True Then
total += 1
End If
MsgBox("Your Mark is " & total)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
If Label3.Text = 0 Then
Timer1.Enabled = False
MsgBox("Timeout")
Else
Label3.Text = Label3.Text - 1
End If
End Sub
End Class
Output:
Result:
Thus the program was executed and its output was verified.
13