0% found this document useful (0 votes)
68 views13 pages

Bcap 235:: Frmpal Object Eventargs

The document discusses four programming tasks: 1) a program to find the sum of digits in a number and check if it is a palindrome, 2) creating an MDI form with child forms that can be arranged, 3) a form to accept book order details dynamically based on number entered, and 4) creating a tree view control with nodes that change the label text color on mouseover.

Uploaded by

PrasannaKB
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views13 pages

Bcap 235:: Frmpal Object Eventargs

The document discusses four programming tasks: 1) a program to find the sum of digits in a number and check if it is a palindrome, 2) creating an MDI form with child forms that can be arranged, 3) a form to accept book order details dynamically based on number entered, and 4) creating a tree view control with nodes that change the label text color on mouseover.

Uploaded by

PrasannaKB
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

BCAP 235: Visual Basic.

NET
Lab

PART A
1. Write a program to find the Sum of digit and check palindrome or not. Accept input
through textbox and display the results in label. Also validate for invalid input such
as empty input, nonnumeric and negative integer.

Design

Source Code:

Public Class frmpal

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


System.EventArgs) Handles btnsum.Click
Dim n, sum, r, t, pal As Integer

sum = 0
pal = 0
n = Val(txtnumber.Text)

If txtnumber.Text = "" Then

MsgBox("Textbox cannot be blank!!! Please enter the number")

txtnumber.Focus()

ElseIf IsNumeric(n) And n > 0 Then

t=n
While n <> 0
r = n Mod 10
sum += r
pal = pal * 10 + r
n \= 10

End While

txtsum.Text = sum

If pal = t Then

lblpal.Text = "IT IS PALINDROM"

Else

lblpal.Text = "IT IS NOT PALINDROM"

End If

Else

MsgBox("Please enter valid number")

Exit Sub

End If

End Sub

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


System.EventArgs) Handles btnclear.Click

txtnumber.Text = ""
txtsum.Text = ""
lblpal.Text = ""

End Sub

Private Sub btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles btnexit.Click
End

End Sub

End Class
Output:
2. Create 3 forms Yourself.vb, Yourplace.vb and College.vb where each includes a rich
textbox containing the respective information. Create an MDI form with menu options to
open all these forms as child forms, closing them and rearrange the child forms as follows.
Child Forms Window
For example
Open Cascade
Close Tile Horizontal
Tile vertical
Arrange icons.

Design
Source Code:
Public Class frmmdi

Private Sub AboutYourselfToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles AboutYourselfToolStripMenuItem.Click

Dim child As New MDIChildYourself


child.MdiParent = Me
child.Show()

End Sub

Private Sub AboutYourPlaceToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles AboutYourPlaceToolStripMenuItem.Click

Dim child As New MDIChildYourplace


child.MdiParent = Me
child.Show()

End Sub

Private Sub AboutCollegeToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles AboutCollegeToolStripMenuItem.Click

Dim child As New MDIChildCollege


child.MdiParent = Me
child.Show()

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 ArangeIconToolStripMenuItem_Click(ByVal sender As System.Object, ByVal


e As System.EventArgs) Handles ArangeIconToolStripMenuItem.Click

Me.LayoutMdi(MdiLayout.ArrangeIcons)

End Sub

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


System.EventArgs) Handles CloseToolStripMenuItem.Click

MDIChildCollege.Close()
MDIChildYourplace.Close()
MDIChildYourself.Close()
Me.Close()

End Sub

End Class
Output:
MDI Form Cascade

Tile Horizontal Tile Vertical

Arrange Icon
3. Design a form to accept number of books to be ordered to a shop in a textbox. By clicking a
button ‘Continue’, if accepted number is > 0, then place required number of textboxes on the
form to accept the details Title, Author and Copies, during run time to accept details of
specified number of books. By clicking a button ‘Next’ on this form, enabling progression
bar, send the details to another form to show the summary of the books ordered.

DESIGN:

Source Code
Public Class frmbooks

Dim n, i As Integer
Dim tbt(10) As TextBox
Dim tba(10) As TextBox
Dim tbc(10) As TextBox
Dim lbt, lba, lbc As Label

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


System.EventArgs) Handles btncontinue.Click
n = Val(txtno.Text)
If n > 0 Then
lblh1.Visible = True
lbt = New Label
lbt.Text = "TITLE"
lbt.Location = New Point(250, 250)
lbt.Font = New Font("Courier New", 14, FontStyle.Bold)
Me.Controls.Add(lbt)
lba = New Label
lba.Text = "AUTHOR"
lba.Location = New Point(400, 250)
lba.Font = New Font("Courier New", 14, FontStyle.Bold)
Me.Controls.Add(lba)
lbc = New Label
lbc.Text = "COPIES"
lbc.Location = New Point(600, 250)
lbc.Font = New Font("Courier New", 14, FontStyle.Bold)
Me.Controls.Add(lbc)

For i As Integer = 1 To n
tbt(i) = New TextBox
tbt(i).Size = New Size(150, 200)
tbt(i).Location = New Point(200, 200 + 40 * (i + 1))
Me.Controls.Add(tbt(i))

tba(i) = New TextBox


tba(i).Size = New Size(150, 200)
tba(i).Location = New Point(400, 200 + 40 * (i + 1))
Me.Controls.Add(tba(i))

tbc(i) = New TextBox


tbc(i).Size = New Size(150, 200)
tbc(i).Location = New Point(600, 200 + 40 * (i + 1))
Me.Controls.Add(tbc(i))
Next
Else
MsgBox("Enter the valid number")
Exit Sub
End If

End Sub

Private Sub btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles btnexit.Click

End

End Sub

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


System.EventArgs) Handles btnnext.Click

ProgressBar1.Visible = True
Dim j As Integer
ProgressBar1.Minimum = 0
ProgressBar1.Maximum = 300
For j = 0 To 300
ProgressBar1.Value = j
Next

frmorderdetails.Show()
frmorderdetails.Controls.Add(lbt)
frmorderdetails.Controls.Add(lba)
frmorderdetails.Controls.Add(lbc)

For i As Integer = 1 To n
frmorderdetails.Controls.Add(tbt(i))
frmorderdetails.Controls.Add(tba(i))
frmorderdetails.Controls.Add(tbc(i))
Next

End Sub

End Class
Output:
4. Create a tree structure using TreeView control with at least 3 nodes with 2 sublevel nodes
under each node. When any node is clicked display the text in a label and when the mouse
pointer moves to this label change the font color by applying the color selected in default
color dialog box. [Use ColorDialog control and MouseMove() event]

Design:

Source Code
Public Class frmtree

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


System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect

Label2.Text = "You have selected : " & TreeView1.SelectedNode.Text.ToString

End Sub

Private Sub lbldisplay_MouseMove(ByVal sender As Object, ByVal e As


System.Windows.Forms.MouseEventArgs) Handles lbldisplay.MouseMove
ColorDialog1.ShowDialog()
Label2.ForeColor = ColorDialog1.Color

End Sub

End Class

Output:

You might also like