Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 33

SOURCE CODE FOR STUDENTS MARKLIST

Imports System.windows.forms
Module Module1
Sub Main( )
Dim mark1 As Integer
Dim mark2 As Integer
Dim mark3 As Integer
Dim mark4 As Integer
Dim total As Integer
Dim average As Integer
Dim status As String = "Pass"
Dim name As String
Console.Write("Enter a Student Name: ")
name = Console.ReadLine( )
Console.Write("Enter marks for the subject Tamil: ")
mark1 = Console.ReadLine( )
If mark1 < 35 Then
status = "Fail"
End If
Console.Write("Enter marks for the subject English: ")
mark2 = Console.ReadLine( )
If mark2 < 35 Then
status = "Fail"
End If
Console.Write("Enter marks for the subject Maths: ")
mark3 = Console.ReadLine( )
If mark3 < 35 Then
status = "Fail"
End If
Console.Write("Enter marks for the subject Science: ")
mark4 = Console.ReadLine( )
If mark4 < 35 Then
status = "Fail"
End If
total = mark1 + mark2 + mark3 + mark4
Console.WriteLine("Total Marks: " & total)
average = total / 4
Console.WriteLine("Average: " & average)
MessageBox.Show("Student Got " & status)
Console.ReadKey( )
End Sub
End Module

OUTPUT

SOURCE CODE FOR FIBONACCI SERIES


Module Module1
Sub Main( )
Dim a As Integer = 0
Dim b As Integer = 1
Dim c As Integer
Dim i As Integer = 1
Dim temp As Integer
Dim num As Integer
Console.WriteLine("Enter the number to display the fibonacci series: ")
num = Console.ReadLine( )
Console.WriteLine("FIBONACCI SERIES")
Console.WriteLine(a)
Console.WriteLine(b)
Do While i <= num
c=a+b
Console.WriteLine(c)
temp = a
a=b
b=c
c = temp
i=i+1
Loop
Console.ReadLine( )
End Sub
End Module
OUTPUT

SOURCE CODE FOR STACK OPERATION


Imports System.Console
Module Module1
Sub Main( )
Clear( )
Dim n, top, push, pop, a(5), item As Integer
top = -1
Do Until n = 5
WriteLine("STACK OPERATIONS")
WriteLine("1.Push")
WriteLine("2.Pop")
WriteLine("3.Display")
WriteLine("4.Exit")
WriteLine("Choose the number")
n = ReadLine( )
Select Case n
Case 1
WriteLine("")
top = top + 1
WriteLine("Enter the item: ")
push = ReadLine( )
a(top) = push
WriteLine("Item " & push & " added")
Case 2
If top = -1 Then
WriteLine("Stack is empty")
Else
item = a(top)
a(top) = 0
top = top - 1
WriteLine("Item " & item & " removed")
End If
Case 3
If top = -1 Then
WriteLine("Stack is empty")
Else
WriteLine("Items are: ")
For pop = 0 To top
WriteLine(a(pop))
Next
End If

Case 4
Exit Do
End Select
Loop
ReadLine( )
End Sub
End Module

OUTPUT

SOURCE CODE FOR PALINDROME


Module Module1
Sub Main( )
Dim txt As String = Nothing
Console.WriteLine("Please enter a string! ")
txt = Console.ReadLine( )
Dim palindrome As Boolean = True
For i As Integer = 0 To txt.Length \ 2
If txt(i) < > txt(txt.Length - i - 1) Then
palindrome = False
Exit For
End If
Next
If palindrome = True Then
Console.WriteLine("Given string is a palindrome! ")
Else
Console.WriteLine("Given string is not a palindrome! ")
End If
Console.ReadKey( )
End Sub
End Module
OUTPUT
Run 1

Run 2

SOURCE CODE FOR ASCENDING AND DESCENDING ORDER


Module Module1
Sub Main( )
Dim n As Integer
Dim arrayelement As Integer = 0
Console.Write("Enter how many numbers: ")
n = Console.ReadLine( )
Dim arraygroup(n - 1) As Integer
Console.WriteLine("Enter the numbers: ")
For i As Integer = 0 To arraygroup.Length - 1
arraygroup(i) = Console.ReadLine( )
Next
System.Array.Sort(arraygroup)
Console.WriteLine("Ascending Order")
For Each arrayelement In arraygroup
Console.WriteLine("{0}", arrayelement)
Next
System.Array.Reverse(arraygroup)
Console.WriteLine("Descending Order")
For Each arrayelement In arraygroup
Console.WriteLine("{0}", arrayelement)
Next
Console.ReadKey( )
End Sub
End Module
OUTPUT

SOURCE CODE FOR AREA OF RECTANGLE


Module calc
Dim length As Integer
Dim breadth As Integer
Dim totarea As Integer
Dim totper As Integer
Sub Main( )
Console.WriteLine("Enter length of the Rectangle")
length = Console.ReadLine( )
Console.WriteLine("Enter breadth of the Rectangle")
breadth = Console.ReadLine( )
area(length, breadth)
perimeter(length, breadth)
Console.WriteLine( )
Console.WriteLine("BY CALL BY VALUE")
Console.WriteLine("****************")
Console.WriteLine("Area of a Rectangle is:{0}", totarea)
Console.WriteLine( )
Console.WriteLine("BY CALL BY REFERENCE")
Console.WriteLine("********************")
Console.WriteLine("Perimeter of a Rectangle is:{0}", totper)
Console.ReadKey( )
End Sub
Sub area(ByVal x As Integer, ByVal y As Integer)
totarea = length * breadth
End Sub
Sub perimeter(ByRef x As Integer, ByRef y As Integer)
totper = 2 * (length + breadth)
End Sub
End Module

OUTPUT

FORM DESIGN

SOURCE CODE FOR CALCULATOR


Option Explicit On
Public Class Form1
Dim FirstNumber As Single
Dim SecondNumber As Single
Dim AnswerNumber As Single
Dim ArithmeticProcess As String
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles
Button1.Click
TextBox1.Text = TextBox1.Text & 1
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles
Button2.Click
TextBox1.Text = TextBox1.Text & 2
End Sub
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles
Button3.Click
TextBox1.Text = TextBox1.Text & 3
End Sub
Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles
Button4.Click
TextBox1.Text = TextBox1.Text & 4
End Sub
Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles
Button5.Click
TextBox1.Text = TextBox1.Text & 5
End Sub
Private Sub Button6_Click(sender As System.Object, e As System.EventArgs) Handles
Button6.Click
TextBox1.Text = TextBox1.Text & 6
End Sub
Private Sub Button7_Click(sender As System.Object, e As System.EventArgs) Handles
Button7.Click
TextBox1.Text = TextBox1.Text & 7
End Sub

Private Sub Button8_Click(sender As System.Object, e As System.EventArgs) Handles


Button8.Click
TextBox1.Text = TextBox1.Text & 8
End Sub
Private Sub Button9_Click(sender As System.Object, e As System.EventArgs) Handles
Button9.Click
TextBox1.Text = TextBox1.Text & 9
End Sub
Private Sub Button0_Click(sender As System.Object, e As System.EventArgs) Handles
Button0.Click
TextBox1.Text = TextBox1.Text & 0
End Sub
Private Sub Buttondot_Click(sender As System.Object, e As System.EventArgs) Handles
Buttondot.Click
TextBox1.Text = TextBox1.Text & "."
End Sub
Private Sub Buttonplus_Click(sender As System.Object, e As System.EventArgs) Handles
Buttonplus.Click
FirstNumber = Val(TextBox1.Text)
TextBox1.Text = ""
ArithmeticProcess = "+"
End Sub
Private Sub Buttonminus_Click(sender As System.Object, e As System.EventArgs)
Handles Buttonminus.Click
FirstNumber = Val(TextBox1.Text)
TextBox1.Text = ""
ArithmeticProcess = "-"
End Sub
Private Sub Buttonmultiply_Click(sender As System.Object, e As System.EventArgs)
Handles Buttonmultiply.Click
FirstNumber = Val(TextBox1.Text)
TextBox1.Text = ""
ArithmeticProcess = "X"
End Sub
Private Sub Buttondivide_Click(sender As System.Object, e As System.EventArgs)
Handles Buttondivide.Click
FirstNumber = Val(TextBox1.Text)

TextBox1.Text = ""
ArithmeticProcess = "/"
End Sub
Private Sub Buttonequal_Click(sender As System.Object, e As System.EventArgs)
Handles Buttonequal.Click
SecondNumber = Val(TextBox1.Text)
If ArithmeticProcess = "+" Then
AnswerNumber = FirstNumber + SecondNumber
End If
If ArithmeticProcess = "-" Then
AnswerNumber = FirstNumber - SecondNumber
End If
If ArithmeticProcess = "X" Then
AnswerNumber = FirstNumber * SecondNumber
End If
If ArithmeticProcess = "/" Then
AnswerNumber = FirstNumber / SecondNumber
End If
TextBox1.Text = AnswerNumber
End Sub
Private Sub ButtonC_Click(sender As System.Object, e As System.EventArgs) Handles
ButtonC.Click
TextBox1.Text = "0" 'Enable to clear
End Sub
Private Sub Buttonbk_Click(sender As System.Object, e As System.EventArgs) Handles
Buttonbk.Click
Dim str As String
Dim len As Single
str = TextBox1.Text
len = str.Length
TextBox1.Text = ""
TextBox1.Text = str.Substring(0, len - 1)
End Sub
End Class

OUTPUT

FORM DESIGN

SOURCE CODE FOR REGISTRATION FORM


FORM 1
Public Class Form1
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
LinkLabel1.LinkClicked
Me.Hide( )
Form2.Show( )
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
MessageBox.Show("Hi your registration is successful!!")
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
End
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
RichTextBox1.Text = ""
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
RadioButton4.Checked = False
RadioButton5.Checked = False
ComboBox1.Text = ""
ComboBox2.Text = ""
ComboBox3.Text = ""
End Sub
End Class

FORM 2
Public Class Form2
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
LinkLabel1.LinkClicked
Me.Close( )
Form1.Show( )
End Sub
End Class
OUTPUT

FORM DESIGN

SOURCE CODE FOR MOUSE EVENT HANDLING


Public Class Form1
Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
Dim xpos, ypos As Integer
Dim fact As Integer = 1
Dim num As Integer
xpos = e.X
ypos = e.Y
num = Val(text1.Text)
If e.Button = Windows.Forms.MouseButtons.Right Then
status.Text = "You Have Right Clicked At the Position " & xpos & " : " & ypos
For i As Integer = 1 To num
fact *= i
Next
ans.Text = "The Factorial Of " & num & " is " & fact
End If
If e.Button = Windows.Forms.MouseButtons.Left Then
status.Text = "You Have Left Clicked At the Position " & xpos & " : " & ypos
ans.Text = "The Squre Root Of " & num & " is " & num * num
End If
End Sub
End Class
OUTPUT
Run 1

Run 2

FORM DESIGN

SOURCE CODE FOR KEYBOARD EVENT HANDLING


Public Class Form1
Dim i As Boolean = True
Dim j As Boolean = True
Private Sub TextBox1_KeyDown(sender As Object, e As
System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
Label1.Text = "Key Down Event Handled: Key pressed is '" + e.KeyCode.ToString + "'
is pressed."
End Sub
Private Sub TextBox1_KeyPress(sender As Object, e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar >= ChrW(48) And e.KeyChar <= ChrW(57) Then
Label2.Text = "KeyPress Event Identified: '" + e.KeyChar.ToString() + "' is pressed."
i = False
End If
If i = True Then
Label2.Text = "KeyPress Event not Identified: No number identified."
End If
End Sub
Private Sub TextBox1_KeyUp(sender As Object, e As
System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
If e.KeyCode >= Keys.F1 And e.KeyCode <= Keys.F19 Then
Label3.Text = "KeyUp Event Identified: Functional Keys used."
j = False
End If
If j = True Then
Label3.Text = "KeyUp Event not Identified: No Functional Keys identified."
End If
End Sub
End Class

OUTPUT

FORM DESIGN

SOURCE CODE FOR NOTEPAD


Public Class Form1
Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles NewToolStripMenuItem.Click
If RichTextBox1.Modified Then
Dim ask As MsgBoxResult
ask = MsgBox("Do you want to save the changes",
MsgBoxStyle.YesNoCancel, "New Document")
If ask = MsgBoxResult.No Then
RichTextBox1.Clear( )
ElseIf ask = MsgBoxResult.Yes Then
SaveFileDialog1.ShowDialog( )
My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName,
RichTextBox1.Text, False)
RichTextBox1.Clear( )
End If
Else
RichTextBox1.Clear( )
End If
End Sub
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OpenToolStripMenuItem.Click
If RichTextBox1.Modified Then
Dim ask As MsgBoxResult
ask = MsgBox("Do you want to save the changes", MsgBoxStyle.YesNoCancel,
"Open Document")
If ask = MsgBoxResult.No Then
OpenFileDialog1.ShowDialog( )
RichTextBox1.Text =
My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName)
ElseIf ask = MsgBoxResult.Yes Then
SaveFileDialog1.ShowDialog( )
My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName,
RichTextBox1.Text, False)
RichTextBox1.Clear( )
End If
Else
OpenFileDialog1.ShowDialog( )
RichTextBox1.Text =
My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName)
End If

End Sub
Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles SaveToolStripMenuItem.Click
SaveFileDialog1.ShowDialog( )
My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName,
RichTextBox1.Text, False)
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ExitToolStripMenuItem.Click
End
End Sub
Private Sub UndoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles UndoToolStripMenuItem.Click
If RichTextBox1.CanUndo Then
RichTextBox1.Undo( )
End If
End Sub
Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CutToolStripMenuItem.Click
If RichTextBox1.SelectionLength > 0 Then
My.Computer.Clipboard.SetText(RichTextBox1.SelectedText)
End If
RichTextBox1.SelectedText = ""
End Sub
Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CopyToolStripMenuItem.Click
If RichTextBox1.SelectionLength > 0 Then
My.Computer.Clipboard.SetText(RichTextBox1.SelectedText)
End If
End Sub
Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles PasteToolStripMenuItem.Click
If My.Computer.Clipboard.ContainsText Then
RichTextBox1.Paste( )
End If
End Sub

Private Sub SelectAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles SelectAllToolStripMenuItem.Click
RichTextBox1.SelectAll( )
End Sub
Private Sub FontToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles FontToolStripMenuItem.Click
FontDialog1.ShowDialog( )
RichTextBox1.Font = FontDialog1.Font
End Sub
Private Sub FontColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles FontColorToolStripMenuItem.Click
ColorDialog1.ShowDialog( )
RichTextBox1.ForeColor = ColorDialog1.Color
End Sub
End Class

OUTPUT

FORM DESIGN

SOURCE CODE FOR TREEVIEW CONTROL


Imports System.Windows.Forms.Form
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Dim i As New TreeNode
Dim a, b As New TreeNode
Dim a1, a2, a3 As New TreeNode
Dim b1, b2, b3 As New TreeNode
Dim z1, z2, z3 As New TreeNode
Dim x1, x2, x3 As New TreeNode
Dim y1, y2, y3 As New TreeNode
Dim m1, m2, m3 As New TreeNode
Dim n1, n2, n3 As New TreeNode
Dim o1, o2, o3 As New TreeNode
i.Text = "Library"
a.Text = "Subject books"
b.Text = "Common books"
a1.Text = "Computer science"
a2.Text = "Commerce"
a3.Text = "Literature"
z1.Text = "C++"
z2.Text = "C"
z3.Text = "C#"
x1.Text = "Financial statements"
x2.Text = "Theory of accounting"
x3.Text = "Accountacy and aduiting"
y1.Text = "Poems"
y2.Text = "Patriotic essays"
y3.Text = "Shaksphere's drama"
b1.Text = "Novels"
b2.Text = "Magazines"
b3.Text = "Comics"
m1.Text = "Crime novels"
m2.Text = "Romantic novels"
m3.Text = "Horror novels"
n1.text = "Sports magazines"
n2.text = "Tamil magazines"
n3.text = "Computer magazines"
o1.text = "Tom and Jerry"
o2.Text = "Timon and Pumba"

o3.Text = "Vicky and Vetal"


TreeView1.Nodes.Add(i)
i.Nodes.Add(a)
i.Nodes.Add(b)
a.Nodes.Add(a1)
a1.Nodes.Add(z1)
a1.Nodes.Add(z2)
a1.Nodes.Add(z3)
a.Nodes.Add(a2)
a2.Nodes.Add(x1)
a2.Nodes.Add(x2)
a2.Nodes.Add(x3)
a.Nodes.Add(a3)
a3.Nodes.Add(y1)
a3.Nodes.Add(y2)
a3.Nodes.Add(y3)
b.Nodes.Add(b1)
b1.Nodes.Add(m1)
b1.Nodes.Add(m2)
b1.Nodes.Add(m3)
b.Nodes.Add(b2)
b2.Nodes.Add(n1)
b2.Nodes.Add(n2)
b2.Nodes.Add(n3)
b.Nodes.Add(b3)
b3.Nodes.Add(o1)
b3.Nodes.Add(o2)
b3.Nodes.Add(o3)
End Sub
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
TextBox1.Text = e.Node.Text
TextBox2.Text = e.Node.FullPath
End Sub
End Class

OUTPUT

You might also like