EX.NO: 1 ***********************************************************************
Write a program to find the Sum of digit and check palindrome or not and display the results in text box and label.
***********************************************************************
Public Class Form1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.Click
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btngenerate.Click
Dim n, r, rev, n1, sum As Integer
n = txtno.Text
rev = 0
sum = 0
n1 = n
If (txtno.Text = "") Then
MsgBox("enter the no")
Else
While (n > 0)
r = n Mod 10
rev = rev * 10 + r
sum = sum + r
n = n / 10
End While
If (rev = n1) Then
lblresult.Text = Str(n1) + "is palindrome"
Else
lblresult.Text = Str(n1) + "is not palindrome"
End If
End If
txtsum.Text = sum
End Sub
Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.Click
txtno.Text = ""
txtsum.Text = ""
End Sub
End Class
OUTPUT:
EX.NO: 2 ***********************************************************************
Write a program to count the number of vowels, words, digits, special characters in an inputted screen and display
***********************************************************************
Public Class Form1
Private Sub BtnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExit.Click
Me.Close()
End Sub
Private Sub BtnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClear.Click
TxtA.Text = ""
txtE.Text = ""
txtI.Text = ""
TxtO.Text = ""
TxtU.Text = ""
TxtVowels.Text = ""
TxtDigits.Text = ""
TxtSplChar.Text = ""
TxtWords.Text = ""
TxtStrings.Text = ""
Txtinput.Text = ""
End Sub
Private Sub Txtinput_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Txtinput.TextChanged
If Txtinput.Text = "" Then
MsgBox("enter string ", MsgBoxStyle.Exclamation, "Vowels")
End If
End Sub
Private Sub BtnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnFind.Click
Dim st, st1 As String
Dim L, i As Integer
Dim acount, icount, ocount, ucount, ecount, vcount, scount, wcount, ncount, sccount As Integer
st = Trim(Txtinput.Text)
st = LCase(st)
l = Len(st)
For i = Len(st) To 1 Step -1
st1 = Mid(st, i, 1)
If st1 = "a" Then
acount = acount + 1
vcount = vcount + 1
ElseIf st1 = "e" Then
ecount = ecount + 1
vcount = vcount + 1
ElseIf st1 = "i" Then
icount = icount + 1
vcount = vcount + 1
ElseIf st1 = "o" Then
ocount = ocount + 1
vcount = vcount + 1
ElseIf st1 = "u" Then
ucount = ucount + 1
vcount = vcount + 1
End If
If (Asc(st1) >= 65 And Asc(st1) <= 90 Or Asc(st1) >= 97 And Asc(st1) <= 122) Then
scount = scount + 1
ElseIf (Asc(st1) >= 48 And Asc(st1) <= 57) Then
ncount = ncount + 1
ElseIf (st1 = " " Or st1 = "\t" Or st1 = "\n") Then
wcount = wcount + 1
Else
sccount = sccount + 1
End If
Next i
TxtA.Text = CStr(acount)
txtE.Text = CStr(ecount)
txtI.Text = CStr(icount)
TxtO.Text = CStr(ocount)
TxtU.Text = CStr(ucount)
TxtVowels.Text = CStr(vcount)
TxtDigits.Text = CStr(ncount)
TxtSplChar.Text = CStr(sccount)
TxtWords.Text = CStr(wcount + 1)
TxtStrings.Text = CStr(scount)
End Sub
End Class
OUTPUT:
EX.NO: 3 **********************************************************************
Write a program to select a course from a list box and display the fees and regulation using the text boxes and labels (Fees maintained in an array in the program)
*********************************************************************
Public Class Form1
Private Sub BtnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExit.Click
Me.Close()
End Sub
Private Sub BtnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClear.Click
Txt1Year.Text = ""
Txt2Year.Text = ""
Txt3Year.Text = ""
Label5.Text = ""
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lstcourse.Items.Add("BCA")
lstcourse.Items.Add("BBM")
lstcourse.Items.Add("BCOM")
lstcourse.Items.Add("BA")
End Sub
Private Sub lstcourse_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstcourse.SelectedIndexChanged
Dim BCA As Integer()
BCA = New Integer() {25000, 23000, 20000}
Dim BBM As Integer() = New Integer() _
{10000, 9700, 8000}
Dim BCOM As Integer() = New Integer() _
{12000, 13000, 10900}
Dim BA As Integer() = New Integer() _
{12000, 7000, 8500}
If lstcourse.SelectedItem = "BCA" Then
Txt1Year.Text = BCA(0)
Txt2Year.Text = BCA(1)
Txt3Year.Text = BCA(2)
Label5.Text = "student from commerce & scince background with passing parcentage of 50%"
ElseIf lstcourse.SelectedItem = "BBM" Then
Txt1Year.Text = BBM(0)
Txt2Year.Text = BBM(1)
Txt3Year.Text = BBM(2)
Label5.Text = "student from commerce & scince background with passing parcentage of 40%"
ElseIf lstcourse.SelectedItem = "BCOM" Then
Txt1Year.Text = BCOM(0)
Txt2Year.Text = BCOM(1)
Txt3Year.Text = BCOM(2)
Label5.Text = "student from commerce & scince background with passing parcentage of 45%"
ElseIf lstcourse.SelectedItem = "BA" Then
Txt1Year.Text = BA(0)
Txt2Year.Text = BA(1)
Txt3Year.Text = BA(2)
Label5.Text = "student from commerce & Arts background with passing parcentage of 50%"
End If
End Sub
End Class
OUTPUT:
EX.NO: 4 ***********************************************************************
Create an MDI form with several child forms. (At least 3 with proper information) Use menu options to open all child for/ms together, closing them and rearrange the child forms.
Child Forms Window
Open Cascade
Close Tile Horizontal
Tile vertical
Arrange icons.
**********************************************************************
Public Class Form1
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
Dim fm2 As New form2
Dim fm3 As New form3
Dim fm4 As New form4
fm2.show()
fm3.show()
fm4.show()
fm2.mdiparent = Me
fm3.mdiparent = Me
fm4.mdiparent = Me
ToolStripStatusLabel1.Text = "Child forms"
Me.LayoutMdi(MdiLayout.Cascade)
End Sub
Private Sub ClearToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearToolStripMenuItem.Click
'Close all Child forms of Parent.
For Each Childform As Form In Me.MdiChildren
Childform.Close()
Next
End Sub
Private Sub CascadeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CascadeToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.Cascade)
End Sub
Private Sub TilehorizontalToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TilehorizontalToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.TileHorizontal)
End Sub
Private Sub TileverticalToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TileverticalToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.TileVertical)
End Sub
Private Sub ArrangeIconsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ArrangeIconsToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.ArrangeIcons)
End Sub
End Class
Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With Label1
.Height = 1000
.Width = 4000
.Text = "Carmel college modankap"
.ForeColor = Color.Blue
.BackColor = Color.Aqua
End With
With RichTextBox1
.Height = 1000
.Width = 4000
RichTextBox1.Text = "Carmel college modankap,is a new venue..."
.ForeColor = Color.Brown
.BackColor = Color.Aqua
End With
End Sub
End Class
Public Class Form3
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With Label1
.Height = 1000
.Width = 4000
.Text = "College Crest and Motto"
.ForeColor = Color.Blue
.BackColor = Color.Aqua
End With
With RichTextBox1
.Height = 1000
.Width = 4000
RichTextBox1.Text = "Thy Light Our Guide"
.ForeColor = Color.Brown
.BackColor = Color.Aqua
End With
End Sub
End Class
Public Class Form4
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With Label1
.Height = 1000
.Width = 4000
.Text = "Carmel college Vision"
.ForeColor = Color.Blue
.BackColor = Color.Aqua
End With
With RichTextBox1
RichTextBox1.Text = "The Gradute Students of Carmel College shall imbibe the values and become persons for others,at the same time they will be knoweledgeable,confident abd principle-centred humane persons."
.ForeColor = Color.Brown
.BackColor = Color.Aqua
End With
End Sub
End Class
OUTPUT:
EX.NO: 5 **********************************************************************
Design a VB interface containing
a. A picture box whose picture should be changed every 5 second (use 5 pictures) .
b. Textboxes to display date & time and day greeting based on time.
c. Use scrollbars to control font size and background color (RGB) of the textbox that shows greeting.
**********************************************************************
Public Class Form1
Dim s As Integer = 0
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Static s As Integer
Select Case (s)
Case 1
PictureBox1.Image = Image.FromFile("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Sunset.jpg")
Case 2
PictureBox1.Image = Image.FromFile("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water lilies.jpg")
Case 3
PictureBox1.Image = Image.FromFile("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Winter.jpg")
Case 4
PictureBox1.Image = Image.FromFile("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\avi.jpg")
Case 5
PictureBox1.Image = Image.FromFile("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\b.jpg")
s = 0
End Select
s = s + 1
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Txtdate.Text = Format(Now, "dddd,mmmm d,yyy") & " " & Format(Now, "hh:mm:ss")
If (TimeString >= "00:00:01" And TimeString <= "11:59:59") Then
Txtgreet.Text = "Good Morning"
ElseIf (TimeString >= "12:00:01" And TimeString <= "15:59:59") Then
Txtgreet.Text = "Good Afternoon"
ElseIf (TimeString >= "16:00:00" And TimeString <= "17:59:59") Then
Txtgreet.Text = "Good Evening"
Else
Txtgreet.Text = "Good Night"
End If
HScrollBar4.Maximum = 60
HScrollBar4.Minimum = 10
HScrollBar4.SmallChange = 2
HScrollBar4.LargeChange = 5
End Sub
Private Sub HScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll
'Call docolor()
HScrollBar1_change()
End Sub
Private Sub HScrollBar1_change()
Call docolor()
End Sub
Private Sub HScrollBar2_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar2.Scroll
'Call docolor()
HScrollBar2_change()
End Sub
Private Sub HScrollBar2_change()
Call docolor()
End Sub
Private Sub HScrollBar3_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar3.Scroll
'Call docolor()
HScrollBar3_change()
End Sub
Private Sub HScrollBar3_change()
Call docolor()
End Sub
Private Sub docolor()
Dim clr As Color
clr = Color.FromArgb(HScrollBar1.Value, HScrollBar2.Value, HScrollBar3.Value)
txtgreet.BackColor = clr
End Sub
Private Sub HScrollBar4_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar4.Scroll
txtgreet.Font = New System.Drawing.Font("Times new roman", HScrollBar4.Value)
End Sub
OUTPUT:
EX.NO: 6 ***********************************************************************
Create a file browser (similar to Windows Explorer). The file browser should have a Tree View, which allows the user to browse directories and double-clicking a directory in the Tree View should browse it. Create Tree Views in Code.(3 child directories)
***********************************************************************
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TreeView1.Nodes.Clear()
Dim root = New TreeNode("D:")
TreeView1.Nodes.Add(root)
TreeView1.Nodes(0).Nodes.Add(New TreeNode("avin"))
TreeView1.Nodes(0).Nodes(0).Nodes.Add(New TreeNode("images"))
TreeView1.Nodes(0).Nodes(0).Nodes.Add(New TreeNode("my documents"))
TreeView1.Nodes(0).Nodes(0).Nodes(1).Nodes.Add(New TreeNode("My Music"))
TreeView1.Nodes(0).Nodes(0).Nodes(1).Nodes.Add(New TreeNode("My Pictures"))
TreeView1.Nodes(0).Nodes(0).Nodes.Add(New TreeNode("ankush"))
Me.Text = "MY COMPUTER"
End Sub
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
Label1.Text = e.Node.FullPath
Label2.Text = e.Node.Text
End Sub
Private Sub TreeView1_NodeMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseDoubleClick
System.Diagnostics.Process.Start(e.Node.FullPath)
End Sub
End Class
OUTPUT:
EX.NO: 1 **********************************************************************
Create a VB interface with menu options STRING and NUMBER. Under String use option TOGGLE CASE (convert lower to uppercase and upper to lowercase letters) and NUMBER use option FACTORIAL. Use user defined functions to find FACTORIAL and TOGGLE CASE. If the option selected is NUMBER, apply the validation for entering only the +ve number. Accept the necessary inputs through input box.
**********************************************************************
Public Class toggleform
Private Sub toggleform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = InputBox("enter string", "string")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
toggle()
End Sub
Function toggle() As String
Dim str As String
Dim i As Integer
Dim res As String
Dim txt As String
txt = TextBox1.Text
For i = 0 To txt.Length - 1
str = txt.Chars(i)
If System.Char.IsLower(str) Then
res = str.ToUpper
Else
res = str.ToLower
End If
TextBox2.Text = TextBox2.Text & res
Next
Return (TextBox2.Text)
End Function
End Class
Public Class Factform
Private Sub Factform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As Integer
a = CInt(InputBox("enter number", "number"))
TextBox2.Text = factorial(a)
End Sub
Function factorial(ByVal number) As Long
If number <= 1 Then
Return (1)
Else
Return number * factorial(number - 1)
End If
End Function
End Class
OUTPUT:
EX.NO: 2 **********************************************************************
Design a VB interface to add, remove, search and clear the items in a combo box. The item name to be added, removed or searched can be accepted through input box. Use a general procedure to find the existence of item before deleting or while searching.
**********************************************************************
Public Class Form1
Dim item As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
item = InputBox("enter string", "string")
ComboBox1.Items.Add(item)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
item = InputBox("remove string", "string")
If ComboBox1.Items.Contains(item) Then
ComboBox1.Items.Remove(item)
MsgBox(item & " " & "removed", )
Else
MsgBox("No item found",MsgBoxStyle.Exclamation)
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
item = InputBox("search string", "string")
If ComboBox1.Items.Contains(item) Then
MsgBox(item & " " & "search")
Else
MsgBox("No item found", MsgBoxStyle.Critical)
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
item = InputBox("clear string", "string")
If ComboBox1.Items.Contains(item) Then
MsgBox(item & " " & "clear")
Else
MsgBox("No item found")
End If
End Sub
End Class
OUTPUT:
EX.NO: 3 **********************************************************************
Write a program to invoke a default color dialog box, default font dialog box by instantiating the color dialog class and font dialog class respectively.
**********************************************************************
Public Class Form1
Private Sub BtnColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnColor.Click
colordialog1.color = Me.BackColor
ColorDialog1.AllowFullOpen = True
If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
RichTextBox1.ForeColor = ColorDialog1.Color
End If
End Sub
Private Sub BtnFont_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnFont.Click
FontDialog1.Font = RichTextBox1.Font
If FontDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
RichTextBox1.Font = FontDialog1.Font()
End If
End Sub
End Class
OUTPUT:
EX.NO: 4 **********************************************************************
Write a program that allows the user to enter Strings in a Textbox. Each String input is added to a List Box. As each String is added to the List Box, ensure that the Strings are in sorted order. Any sorting method may be used. [Note: Do not use property Sort]
**********************************************************************
Public Class Form1
Dim i, n, j As Integer
Dim words(10), temp As String