You are on page 1of 15

Assignment on Form

1. Design a Form with Caption "my First Program".


Set the backcolor at design Blue, at Load TIME Green, at Click White at Unload Pink.
Also Set the CDROM icon to the form.

2. Without using any object on the Form, Write on Separate Lines

Name : XYZ
Class : BBA – IIIA (SS)
Summary of marks
Aggregate
---------------------------------------------
Sem -1 70%
Sem-2 60%
----------------------------------------------
Average 65%
-----------------------------------------------

2. Without using object, print the two nos on the form 10 & 20.
(i) During Mouse Press, Will Add the two nos & display Sum =30. Also the mouse
pointer will change to Hourglass.
(ii) After KeyPress, will Display the Product=200.

3. Change the Properties of Form to hide all the three button (Minimize,Maximize & Restore)
4. Change the Properties of Form to hide all the two button (Minimize & Maximize).Also
Change the Change the Picture on Background of Form to any Picture during Run Window like
Sunset.
6. Design a form in which mouse pointer becomes hourglass when anywhere clicked on form .

7 . Design a form in which the sum of 2 numbers gets printed when anywhere clicked on the
form.
* The sum of 2 numbers gets printed when anywhere clicked on the form.
* The subtraction of 2 numbers gets printed when any key pressed

9 Design a simple calculator in vb.


Assignment 2 for Label, Text boxes & Command Button.

1. Design a Form with 1 textbox & 1 Label. Name the Text box as TxtOne & Label as
LblOne. Change the Caption of Both Textbox & Label as “Welcome To
VB”.Change the Appearance of Textbox & Label to make them Look-Alike.

2. Design a Form with 2 Textbox & 1 Command Button. Name the Textbox as Txt1 &
Txt2. Clear their Text during the design time. Name the Command Button as
CmdCopy & Write Copy in the Caption of Command Button.
Write the Code in the Click Event of Command Button, as to Copy the Content of
Txt1 into Txt2.

3. Design a Form with 2 Textbox . Name the Textbox as Txt1 & Txt2.Write Suitable
code so that whatever you write in the Txt1 is also written in Txt2.

4. Design a Form Do not put any control , Just Write the Caption of Form as “My First
Program”. Also Write Your Name in top left Corner in the Form.

5. Design a Simple Calculator: Containing


1st Label as LblOne name with Caption “Enter the First Number”.
2nd Label as LblTwo name with Caption “Enter the Second Number”.
3rd Label as LblResult name with Caption “Result”.
1st Textbox as TxtOne with Blank Text.
2nd Textbox as TxtTwo with Blank Text.
3rd Textbox as TwtResult.
Command Button1 name as CmdAdd with Caption ADD
Command Button1 name as CmdMinus with Caption Minus
Command Button1 name as CmdMult with Caption Multiply
Command Button1 name as CmdDivide with Caption Divide
One Command Button EXIT to End the Program.

6. Design a Form with With 3 Text Box, to enter Name of Student, Fathers
Name & Date Of Birth. Display a Message Box on the click event of Command
Button to Display “Name S/o Fathers Name & DOB”.
Assignment 3 using Option Button, Check Boxes and Shape Control

Q1. WAP to Show shape corresponding to the Option Selected using Option button &
Shape Control. Initially during form load no option should be selected & shape is also not
displayed.

Q2. WAP to Draw shape corresponding to Circle, Square (Rounded & Not Rounded), Rectangle
(Rounded & Not Rounded) with Height & Width Specified using option button in a frame,
checkbox in another frame, Textbox & label for height & width in another frame. Use Command
button to draw the shape. Also initially make sure that no option button, check box is selected &
Shape Control is also not visible
Q3. WAP to show the form as below corresponding to the Option selected using Option button &
Check box Control. Change the font style and font color of the text typed in the name of the
student and address text boxes.
Assignment4 using Option Button, Check Boxes, ScrollBar and Shape
Control

WAP to Increase / decrease the size of Shape Control using Scroll Bar.
Assignment5 – List Box Q1. WAP that uses a List Box Control. Give
an Option for the Following:-
1. To add a new Item in the List box from Text
Box.
2. Display the Updated Total No of Item in the
List
List Box 3. Display the Item Corresponding to
a. 1st Item in List
b. Last Item in List
c. Item at a specific position from Top
4. Delete the Item from the list option :
a. 1st Item Delete
b. Last item Delete
c. Delete the Selected Item
Note after each operation (Add, Delete) from List the
Text Box
total no item should be updated.

Q2. Use 2 List Box Control List 1 & List 2.


Add Items in List 1 as State Capital of India.
& in List2 add States of India.
o Use 1 Command Button Cmd_Right (Caption
>>) to move the selected item from List 1 to
List 2.

o Use 2nd Command Button Cmd_Left


(Caption <<) to move the selected item from
List 2 to List1.
Assignment6 – Combo Box
WAP using Combo Box to Perform the
Following Tasks:
o To add a new Item in the Combo box from
Text Box of combo box at the location
indicated by the option button
o Use one button (Caption Add, name
Cmd_Add) to add the option selected
o To delete the item from the Combo box at
the location indicated by the option button
o Use a Command Button Cmd_Del( Caption
Delete) to Delete the Option Selected.
o To display the item from the Combo box at
the location indicated by the option button
o Total items in the combo box should also be
updated accordingly
o Use a Command Button
Cmd_Exit (Caption Exit) from the Program.
Also Use the ESC Key to link the Exit

Assignment7 – Image Control using List box control

Design a form to perform the


following tasks:
o Add list of items to be
displayed in the image
control
o Add one command button
(Caption Show) to show
selected picture from the
list in image control.
o Set the stretch property
true to fit the image in the
image control
Assignment8 –File System control

Private Sub Dir1_Change()


File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()


Dir1.Path = Drive1.Drive
End Sub

Private Sub File1_PathChange()


File1.Path = Dir1.Path
End Sub

Private Sub Form_Load()


Drive1.Drive = "c:"
Dir1.Path = Drive1.Drive
File1.Path = Dir1.Path
End Sub

Private Sub txtpattern_Change()


File1.Pattern = txtpattern.Text
End Sub
Assignment9 – Picture & Image Control using File system control

WAP using System Control (Drive Control, Directory Control, File Control) and Image Control.
Perform he Following Tasks:
o Select the file having extension .jpg, .bmp and .gif and then show the image in image
control
o Set the stretch property true and notice the effect

Private Sub dirMyDirectory_Change()


'Update the file path to the directory path
filMyFile.Path = dirMyDirectory.Path
filMyFile.Pattern = "*.gif;*.jpg;*.bmp"
End Sub

Private Sub drvMyDrive_Change()


'Update the directory path to drive
dirMyDirectory.Path = drvMyDrive.Drive
End Sub

Private Sub filMyFile_Click()


Path = filMyFile.Path
Text1.Text = Path + "\" + filMyFile
imgMyImage.Picture = LoadPicture(Text1.Text)
End Sub

Private Sub Form_Load()


dirMyDirectory.Path = drvMyDrive.Drive
End Sub
Assignment10 – Timer control using shape control

Design a form shown below to perform the following tasks


1. set the timer control property false at the form load event
2. add two buttons having captions Start and Stop
3. place the timer control on the form
4. change the shape, height and width of the shape control when the start button is clicked
5. when the stop button is clicked, it will stop the timer control

Assignment11 – Picture & Image Control using File system control


Dim Pic_Height, Pic_Width As Long
Dim Img_Height, Img_Width As Long
Dim Pic_Left, Pic_Top As Long
Dim Img_Left, Img_Top As Long

Private Sub Cmb_Change()


If Cmb.Text = "" Then
File1.Pattern = "*.*"
Else
File1.Pattern = Cmb.Text
End If
End Sub

Private Sub Cmb_Click()


If Cmb.Text = "" Then
File1.Pattern = "*.*"
Else
File1.Pattern = Cmb.Text
End If
End Sub

Private Sub CmdImg_Click()


Img1.Height = Val(TxtHeightImg.Text)
Img1.Width = Val(TxtWidthImg.Text)
End Sub

Private Sub CmdPic_Click()


Pic1.Height = Val(TxtHeightPic.Text)
Pic1.Width = Val(TxtWidthPic.Text)
End Sub

Private Sub CmdShow_Click()


Dim File As Variant
File = Dir1.Path & "\" & File1.List(File1.ListIndex)
Pic1.Picture = LoadPicture(File)
Img1.Picture = LoadPicture(File)
If OptYesImg.Value = True Then
Call OptYesImg_Click
Else
Call OptNoImg_Click
End If
If OptYesPic.Value = True Then
Call OptYesPic_Click
Else
Call OptNoPic_Click
End If
End Sub

Private Sub Dir1_Change()


File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()


Dir1.Path = Drive1.Drive
End Sub

Private Sub Form_Load()


Cmb.AddItem "*.txt"
Cmb.AddItem "*.doc"
Cmb.AddItem "*.html"
Cmb.AddItem "*.jpg"
Cmb.AddItem "*.jpeg"
Cmb.AddItem "*.bmp"
Cmb.AddItem "*.ico"
Cmb.AddItem "*.cur"
Pic_Height = Pic1.Height
Pic_Width = Pic1.Width
Img_Width = Img1.Width
Img_Height = Img1.Height
Pic_Left = Pic1.Left
Pic_Top = Pic1.Top
Img_Left = Img1.Left
Img_Top = Img1.Top

End Sub

Private Sub OptNoImg_Click()

Img1.Stretch = False
If TxtHeightImg.Text <> "" Then
Img1.Height = Val(TxtHeightImg.Text)
Else
Img1.Height = Img_Height
End If
If TxtWidthImg.Text <> "" Then
Img1.Width = Val(TxtWidthImg.Text)
Else
Img1.Width = Img_Width
End If
Img1.Left = Img_Left
Img1.Top = Img_Top

LblImg.Caption = "Image with No Stretch"


End Sub

Private Sub OptNoPic_Click()


Pic1.AutoSize = False
If TxtHeightPic.Text <> "" Then
Pic1.Height = Val(TxtHeightPic.Text)
Else
Pic1.Height = Pic_Height
End If
If TxtWidthPic.Text <> "" Then
Pic1.Width = Val(TxtWidthPic.Text)
Else
Pic1.Width = Pic_Width
End If
Pic1.Left = Pic_Left
Pic1.Top = Pic_Top
LblPic.Caption = "Picture with No Autosize"
End Sub

Private Sub OptYesImg_Click()


Img1.Stretch = True
LblImg.Caption = "Image with Stretch TRUE"
End Sub

Private Sub OptYesPic_Click()


Pic1.AutoSize = True
LblPic.Caption = "Picture with Autosize TRUE"
End Sub

Assignment12 – Line Control

' Using the Line control


Option Explicit

Private Sub cmdChange_Click()


Dim v As Integer
v = txtStyle.Text
If v >= 0 And v <= 6 Then
linLine.BorderStyle = v
Else
linLine.BorderStyle = 1
txtStyle.Text = 1
End If
v = txtWidth.Text
If v >= 1 And v <= 100 Then
' If v is greater than 1 some BorderStyle
' properties are ignored
linLine.BorderWidth = v
Else
linLine.BorderWidth = 1
txtWidth.Text = 1
End If
End Sub

Private Sub cmdClear_Click()


Cls
txtWidth = " "
txtStyle = " "
txtWidth.SetFocus 'After clearing the text boxes the focus will transfer to txtInput1
End Sub

Private Sub cmdExit_Click()


End 'Terminating application
End Sub

Assignment12 –Timer control


.
Q1. WAP to Display the Day of Week, Day in Numeric, Q2. WAP to Display the Stop Watch using Timer
Complete Month Name, Year in YYYY Format. Control
Also Display the Time in AM/PM Format
Assignment 13 on sub procedure and function procedure
Q1 design a form and write subprocedure to calculate
• simple interest by getting the values of principle, rate and time from the text boxes
• area of circle
• hypotenuse of a triangle using formula (sqr(a^2+b^2))
• swapping of numbers or text (typed in the text box)

Q2 design a form and write function procedure to calculate


• simple interest by getting the values of principle, rate and time from the text boxes
• area of circle
• hypotenuse of a triangle using formula (sqr(a^2+b^2))