Anda di halaman 1dari 43

1.

Application to build a form where a pizza order can be entered by simply


clicking on check boxes and option buttons

DESIGN
Application - Setting Properties

Set properties of the form,3 Frames, 7 Option Buttons, 6 Check Box, 2 Command
Buttons

Sl.No Control / Object Property Value


1 Form1 Caption Pizza Order
2 Frame 1 Caption Size
3 Frame 2 Caption Toppings
4 Frame 3 Caption Crust Type
5 Option 1(0) Caption Small
6 Option 1(1) Caption Medium
7 Option 1(2) Caption Large
8 Option 2(0) Caption Thin Crust
9 Option 2(1) Caption Thick Crust
10 Option 3(0) Caption Eat In
11 Option 3(1) Caption Take Out
12 Check Box 1(0) Caption Extra Cheese
13 Check Box 1(1) Caption Onions
14 Check Box 1(2) Caption Mushrooms
15 Check Box 1(3) Caption Green Peppers
16 Check Box 1(4) Caption Black Olives
17 Check Box 1(5) Caption Tomatoes
18 Command 1 Caption Build Pizza
19 Command 2 Caption Exit
CODING
Option Explicit
Dim PizzaSize As String
Dim PizzaCrust As String
Dim PizzaWhere As String
Coding for Form:
Private Sub Form_Load()
PizzaSize = "Small"
PizzaCrust = "Thin Crust"
PizzaWhere = "Eat In"
End Sub
Coding for Size Option button:
Private Sub Option1_Click(Index As Integer)
PizzaSize = Option1(Index).Caption
End Sub
Coding for Crust Option button:
Private Sub Option2_Click(Index As Integer)
PizzaCrust = Option2(Index).Caption
End Sub
Coding for Where Option button:
Private Sub Option3_Click(Index As Integer)
PizzaWhere = Option3(Index).Caption
End Sub
Coding for Build Command button:
Private Sub Command1_Click()
'This procedure builds a message box that displays your pizza type
Dim Message As String
Dim i As Integer
Message = PizzaWhere + vbCr
Message = Message + PizzaSize + " Pizza" + vbCr
Message = Message + PizzaCrust + vbCr
For i = 0 To 5
If Check1(i).Value = vbChecked Then Message = Message + Check1(i).Caption + vbCr
Next i
MsgBox Message, vbOKOnly, "Your Pizza"
End Sub
Coding for Exit Command button:
Private Sub Command2_Click()
End
End Sub
OUTPUT
2. Application to book Flight Ticket.

DESIGN
Application - Setting Properties

Set properties of the form,1 Frame, 4 Labels,1 List Box,2 Combo box,2 Command
Buttons

Sl.No Control / Object Property Value


1 Form1 Caption Flight Planner
2 Frame 1 Caption [Blank]
3 Label 1 Caption Flight Planner
Font Style Bold
Font Size 30
4 Label 2 Caption Destination City
Font Style Bold
Font Size 14
5 Label 3 Caption Seat Location
Font Style Bold
Font Size 14
6 Label 4 Caption Meal Preference
Font Style Bold
Font Size 14
7 List1 Sorted True
8 Combo1 Style 2-Dropdown List
9 Combo2 Style 1-Simple
Text [Blank]
10 Command 1 Caption Assign
11 Command 2 Caption Exit
CODING
Coding for Form:
Private Sub Form_Load()
List1.Clear
List1.AddItem "Hubli"
List1.AddItem "Bangalore"
List1.AddItem "Chennai"
List1.AddItem "Tirupati"
List1.AddItem "Delhi"
List1.AddItem "Mumbai"
List1.AddItem "Kerala"
List1.AddItem "Ballari"
List1.AddItem "Goa"
List1.AddItem "Rajasthan"
List1.AddItem "Madhya Pradesh"
List1.AddItem "Shiridi"
List1.AddItem "Jammu & Kashmir"
List1.AddItem "Kolkata"
List1.ListIndex = 0

'Add seat types to first combo box


Combo1.AddItem "First"
Combo1.AddItem "Middle"
Combo1.AddItem "Window"
Combo1.ListIndex = 0

'Add meal types to second combo box


Combo2.AddItem "Chicken"
Combo2.AddItem "Mystery Meat"
Combo2.AddItem "Kosher"
Combo2.AddItem "Vegetarian"
Combo2.AddItem "Fruit Plate"
Combo2.Text = "No Preference"
End Sub
Coding for Assign Command button:
Private Sub Command1_Click()
'Build message box that gives your assignment
Dim Message As String
Message = "Destination: " + List1.Text + vbCr
Message = Message + "Seat Location: " + Combo1.Text + vbCr
Message = Message + "Meal: " + Combo2.Text + vbCr
MsgBox Message, vbOKOnly + vbInformation, "Your Assignment"
End Sub

Coding for Exit Command button:


Private Sub Command2_Click()
End
End Sub

OUTPUT
3. Application to design a form similar to font dialog box.

DESIGN
Application - Setting Properties

Set properties of the form, 4 buttons, 10 Control Array Buttons, 6 labels, 1Textbox,
3 Combo box:

Sl.No Control / Object Property Value


1 Form1 Caption Font Dialog Box
2 Label1 Caption Enter Text
Font Style Bold
Font Size 10
3 Text Box1 Text [Blank]
4 Command1 Caption FONT
5 Command2 Caption Exit
6 Frame1 Caption Font
7 Label2 Caption Font
Font Style Bold
Font Size 10
8 Label3 Caption Font Style
Font Style Bold
Font Size 10
9 Label4 Caption Font Size
Font Style Bold
Font Size 10
10 CheckBox1 Caption Underline
11 CheckBox2 Caption Strikeout
12 Label5 Caption Preview
Font Size 10
13 Label6 Caption AaBbCc
Font Size 10
14 Combo Box1 Text [Blank]
List Times New Roman
Arial Black
Book Antiqua
15 Combo Box2 Text [Blank]
List Bold
Italic
Underline
16 Combo Box3 Text [Blank]
List 8
10
12
14
17 Command3[0] Caption [Blank]
Style Graphical
BackColor Set Any Color
18 Command3[1] Caption [Blank]
Style Graphical
BackColor Set Any Color
19 Command3[2] Caption [Blank]
Style Graphical
BackColor Set Any Color
20 Command3[3] Caption [Blank]
Style Graphical
BackColor Set Any Color
21 Command3[4] Caption [Blank]
Style Graphical
BackColor Set Any Color
22 Command3[5] Caption [Blank]
Style Graphical
BackColor Set Any Color
23 Command3[6] Caption [Blank]
Style Graphical
BackColor Set Any Color
24 Command3[7] Caption [Blank]
Style Graphical
BackColor Set Any Color
25 Command3[8] Caption [Blank]
Style Graphical
BackColor Set Any Color
26 Command3[9] Caption [Blank]
Style Graphical
BackColor Set Any Color
27 Command4 Caption OK
28 Command5 Caption CANCEL
CODING

Coding for Form:


Private Sub Form_Load()
Frame1.Visible = False
End Sub
Coding for FONT command:
Private Sub Command1_Click()
Frame1.Visible = True
Frame1.Enabled = True
End Sub
Coding for EXIT command:
Private Sub Command2_Click()
End
End Sub
Coding for COMBO BOX 1:
Private Sub Combo1_Click()
Label6.Font = Combo1.Text
End Sub
Coding for COMBO BOX 2:
Private Sub Combo2_Click()
If Combo2.Text = "Bold" Then
Label6.FontBold = True
Label6.FontItalic = False
ElseIf Combo2.Text = "Italic" Then
Label6.FontItalic = True
Label6.FontBold = False
ElseIf Combo2.Text = "Bold Italic" Then
Label6.FontBold = True
Label6.FontItalic = True
ElseIf Combo2.Text = "Regular" Then
Label6.FontBold = False
Label6.FontItalic = False
End If
End Sub
Coding for COMBO BOX 3:
Private Sub Combo3_Click()
Label6.FontSize = Combo3.Text
End Sub
Coding for CHECK BOX 1:
Private Sub Check1_Click()
If Check1.Value = 1 Then
Label6.FontUnderline = True
Else
Label6.FontUnderline = False
End If
End Sub
Coding for CHECK BOX 2:
Private Sub Check2_Click()
If Check2.Value = 1 Then
Label6.FontStrikethru = True
Else
Label6.FontStrikethru = False
End If
End Sub
Coding for COLOR Command Buttons:
Private Sub Command3_Click(Index As Integer)
Label6.ForeColor = Command3(Index).BackColor
End Sub
Coding for OK command:
Private Sub Command4_Click()
Text1.Font = Label6.Font
Text1.FontSize = Label6.FontSize
Text1.FontBold = Label6.FontBold
Text1.FontItalic = Label6.FontItalic
Text1.FontUnderline = Label6.FontUnderline
Text1.FontStrikethru = Label6.FontStrikethru
Text1.ForeColor = Label6.ForeColor
Label6.Font = "Times New Roman"
Label6.FontBold = False
Label6.FontItalic = False
Label6.FontSize = 8
Label6.FontUnderline = False
Label6.FontStrikethru = False
Label6.ForeColor = vbBlack
Check1.Value = 0
Check2.Value = 0
Combo1.Text = "Times New Roman"
Combo2.Text = "Regular"
Combo3.Text = 8
Frame1.Visible = False
End Sub
Coding for CANCEL command:
Private Sub Command5_Click()
Label6.Font = "Times New Roman"
Label6.FontBold = False
Label6.FontItalic = False
Label6.FontSize = 8
Label6.FontUnderline = False
Label6.FontStrikethru = False
Label6.ForeColor = vbBlack
Check1.Value = 0
Check2.Value = 0
Combo1.Text = "Times New Roman"
Combo2.Text = "Regular"
Combo3.Text = 8
Frame1.Visible = False
End Sub
OUTPUT
4. Application to develop a Calculator.

DESIGN
Application - Setting Properties
Set properties of the form, 10 Control Array Buttons, 1 label, 10 Command Buttons
Sl.No Control / Object Property Value
1 Form1 Caption Calculator
2 Label1 Alignment Right Justify
Appearance Flat
Borderstyle Fixed Single
Caption [Blank]
Font Size 18
3 Command1[0] Caption 0
4 Command1[1] Caption 1
5 Command1[2] Caption 2
6 Command1[3] Caption 3
7 Command1[4] Caption 4
8 Command1[5] Caption 5
9 Command1[6] Caption 6
10 Command1[7] Caption 7
11 Command1[8] Caption 8
12 Command1[9] Caption 9
13 Command2 Caption .
14 Command3 Caption =
15 Command4 Caption /
16 Command5 Caption *
17 Command6 Caption -
18 Command7 Caption +
19 Command8 Caption CLS
20 Command9 Caption Sqrt
21 Command10 Caption +/-
22 Command11 Caption ^
CODING

Dim a As Double, b As Double, c As Double, s As String


Coding for Number commands:
Private Sub Command1_Click(Index As Integer)
Label1.Caption = Label1.Caption + Command1(Index).Caption
End Sub
Coding for . command:
Private Sub Command2_Click()
If InStr(Label1.Caption, ".") = 0 Then
Label1.Caption = Label1.Caption + Command2.Caption
End If
End Sub
Coding for = command:
Private Sub Command3_Click()
b = Val(Label1.Caption)
If s = "+" Then
c=a+b
ElseIf s = "-" Then
c=a-b
ElseIf s = "*" Then
c=a*b
ElseIf s = "/" Then
c=a/b
ElseIf s = "^" Then
c=a^b
Else
c=b
End If
Label1.Caption = c
End Sub
Coding for / command:
Private Sub Command4_Click()
a = Val(Label1.Caption)
Label1.Caption = ""
s = Command4.Caption
End Sub
Coding for * command:
Private Sub Command5_Click()
a = Val(Label1.Caption)
Label1.Caption = ""
s = Command5.Caption
End Sub
Coding for - command:
Private Sub Command6_Click()
a = Val(Label1.Caption)
Label1.Caption = ""
s = Command6.Caption
End Sub
Coding for + command:
Private Sub Command7_Click()
a = Val(Label1.Caption)
Label1.Caption = ""
s = Command7.Caption
End Sub
Coding for CLS command:
Private Sub Command8_Click()
a=0
s=""
c=0
b=0
Label1.Caption = " "
End Sub
Coding for Sqrt command:
Private Sub Command9_Click()
a = Val(Label1.Caption)
n = Sqr(a)
Label1.Caption = n
End Sub
Coding for +/- command:
Private Sub Command10_Click()
a = Val(Label1.Caption) * -1
Label1.Caption = a
End Sub
Coding for ^ command:
Private Sub Command11_Click()
a = Val(Label1.Caption)
Label1.Caption = " "
s = Command11.Caption
End Sub

OUTPUT
5. Application with drive, directory, file list, picture box to
display the selected image.

DESIGN
Application - Setting Properties

Set properties of the form, 3 Label box, 1 Drive List box, 1 DirListBox, 1
FileListBox, 1 Picture Box, 1 Image Box

Sl. No Control / Object Property Value


1 Form1 Caption IMAGE
2 Label1 Caption Drive
Font Size 12
Font Style Bold
3 Label2 Caption Dir List Box
Font Size 12
Font Style Bold
4 Label3 Caption File
Font Size 12
Font Style Bold
5 Label4 Caption Picture Box
Font Size 12
Font Style Bold
6 Label5 Caption Image Box
Font Size 12
Font Style Bold
7 Image1 Stretch True
CODING

Coding for Drive List box:


Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Coding for Dir List box:
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Coding for File List box:
Private Sub File1_Click()
Picture1.Picture = LoadPicture(Dir1.Path + "\" + File1.FileName)
Image1.Picture = Picture1.Picture
End Sub
Coding for Picture box:
Private Sub Picture1_Click()
Image1.Stretch = True
Image1.Image = LoadPicture(Dir1.Path + "\" + File1.FileName)
End Sub
OUTPUT
6. Application to Convert Temperature from Fahrenheit to Celsius.

DESIGN
Application - Setting Properties
Set properties of the form, 4 Labels,1 Shape,1 Command Buttons,1 Vertical Scroll
Bar.

Sl.No Control / Object Property Value


1 Form1 Caption Temperature
Conversion
2 Shape1 BackColor White
BackStyle 1-Opaque
FillColor Red
FillStyle 7-Diagonal Cross
Shape 4-Rounded Rectangle
3 VScroll1 LargeChange 10
Max -60
Min 120
SmallChange 1
Value 32
4 Label1 Alignment 2-Center
Caption Fahrenheit
FontSize 14
FontStyle Bold
5 Label2 Alignment 2-Center
AutoSize True
BackColor White
BorderStyle 1-Fixed Single
Caption 32
FontSize 14
FontStyle Bold
6 Label3 Alignment 2-Center
Caption Celsius
FontSize 14
FontStyle Bold
7 Label4 Alignment 2-Center
AutoSize True
BackColor White
BorderStyle 1-Fixed Single
Caption 0
FontSize 14
FontStyle Bold
8 Command1 Cancel True
Caption Exit
CODING

Coding for Vertical Scroll Bar:


Private Sub VScroll1_Change()
tempf = VScroll1.Value
Label2.Caption = Str(tempf)
tempc = CInt((tempf - 32) * 5 / 9)
Label4.Caption = Str(tempc)
End Sub

Private Sub VScroll1_Scroll()


tempf = VScroll1.Value
Label2.Caption = Str(tempf)
tempc = CInt((tempf - 32) * 5 / 9)
Label4.Caption = Str(tempc)
End Sub

Coding for Exit Command buttons:


Private Sub Command1_Click()
End
End Sub
OUTPUT
7. MDI Form

DESIGN
Application - Setting Properties

Set properties of the 1 MDIForm,2 forms,4 Label Box,4 Text Box, 4 Command
Buttons.

For MDIForm

1. Go to Tools → Menu Editor.


2. First type Caption Open & Name open, then Click Next and then Press
3. Next type Caption Palindrome, Name Form1 & Index 0, then Click Next.
4. Next type Caption Power, Name Form2 & Index 1, then Click Next and then
Press
5. Next type Caption Windows & Name windows, then Click Next and then
Press
6. Next type Caption Cascade, Name cascade & Index 0, then Click Next.
7. Next type Caption Horizontal, Name horizontal & Index 1, then Click Next.
8. Next type Caption Vertical, Name vertical & Index 2
9. Click OK
For Form1 & Form2
Sl.No Control / Object Property Value
1 Form1 Caption Palindrome
MDIChild True
Name Palindrome
2 Label 1 Caption Enter a Number
Font Style Bold
Font Size 14
3 Text 1 Text [Blank]
4 Command1 Caption Check Palindrome
5 Command2 Caption Exit
6 Form2 Caption Power
MDIChild True
Name Power
7 Label 1 Caption Enter X
Font Style Bold
Font Size 12
8 Label 2 Caption Enter Y
Font Style Bold
Font Size 12
9 Label 3 Caption Power X^Y
Font Style Bold
Font Size 14
10 Text 1 Text [Blank]
11 Text 2 Text [Blank]
12 Text 3 Text [Blank]
13 Command1 Caption Power
14 Command2 Caption Exit
CODING

Coding for MDI Form:


Coding for Form1:
Private Sub Form1_Click(Index As Integer)
Palindrome.Show
End Sub
Coding for Form2:
Private Sub Form2_Click(Index As Integer)
Power.Show
End Sub
Coding for cascade:
Private Sub cascade_Click(Index As Integer)
MDIForm1.Arrange vbCascade
End Sub
Coding for horizontal:
Private Sub horizontal_Click(Index As Integer)
MDIForm1.Arrange vbTileHorizontal
End Sub
Coding for vertical:
Private Sub vertical_Click(Index As Integer)
MDIForm1.Arrange vbTileVertical
End Sub

Coding for Form 1:


Coding for Check Palindrome:
Private Sub Command1_Click()
Dim num As Integer, d As Integer, rev As Integer, n As Integer
rev = 0
n = CInt(Text1.Text)
num = n
While (n > 0)
d = n Mod 10
rev = rev * 10 + d
n = n \ 10
Wend
If num = rev Then
MsgBox ("Given Number is a Palindrome")
Else
MsgBox ("Given Number is not Palindrome")
End If
End Sub

Coding for Exit:


Private Sub Command2_Click()
MsgBox ("Thank you For Using My Application")
Palindrome.Hide
End Sub

Coding for Form 2:


Coding for Power:
Private Sub Command1_Click()
Text3.Text = CInt(Text1.Text) ^ CInt(Text2.Text)
End Sub
Coding for Exit:
Private Sub Command2_Click()
MsgBox ("Thank you For Using My Application")
Power.Hide
End Sub
OUTPUT
8. Application to implement multimedia using windows media player.

DESIGN
Application - Setting Properties
Set properties of the form, 1Text box, 1 Drive List box, 1 DirListBox, 1 FileListBox,
1 Windows Media Player,1 Command Button.
To Enable WINDOWS MEDIAPLAYER Control
1. Go to Project in the menu bar.
2. Select Components.
3. Check the Windows Media Player in the Controls tab.
4. Click Apply & then Close.
Sl. No Control / Object Property Value
1 Form1 Caption MULTIMEDIA PLAYER
2 Text1 Text [Blank]
3 Command1 Caption PLAY
CODING
Coding for Form:
Private Sub Form_Load()
WindowsMediaPlayer1.Visible = False
End Sub
Coding for Drive List box:
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Coding for Dir List box:
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Coding for File List box:
Private Sub File1_Click()
Text1.Text = Dir1.Path + "\" + File1.FileName
End Sub
Coding for PLAY Command:
Private Sub Command1_Click()
WindowsMediaPlayer1.Visible = True
WindowsMediaPlayer1.URL = Text1.Text
End Sub
OUTPUT
9. Application to manage student details using DAO.

DESIGN
Application - Setting Properties

Set properties of the form, 4 Labels,4 Command Buttons,3 Text Boxes,1 Data.

Sl.No Control / Object Property Value


1 Form1 Caption Student Details
2 Label1 Caption STUDENT DETAILS
Font Style Bold
Font Size 14
3 Label2 Caption NAME:
Font Style Bold
Font Size 12
4 Label3 Caption REG.No:
Font Style Bold
Font Size 12
5 Label4 Caption Address:
Font Style Bold
Font Size 12
6 Text1 Text [Blank]
7 Text2 Text [Blank]
8 Text3 Text [Blank]
9 Command1 Caption ADD
10 Command2 Caption UPDATE
11 Command3 Caption DELETE
12 Command4 Caption CLEAR
Steps to link Student Detail Application to Microsoft Access database:

1. In menu bar go to Add-Ins → Visual Data Manager Dialog box called Visdata
will open.
2. In that select File → New → Microsoft access → Version 7.0MDB [Microsoft
Data Base].
3. Give the file name (Database Name) Eg: STUDENT and then click Save.
4. Right click on Database Window & Select New Table.
5. Table Structure Dialog box will open, type the Table Name which you want to
create Eg: STUDENT, & click on Add Field give the field Name as NAME &
Click OK.
6. Give another field name as REG No select the type as Integer &click OK.
7. Give another field name as Address, click OK then Close.
8. Click on Build the Table.
9. Right click on the STUDENT option which is available in the database window,
Select OPEN.
10. Dynaset: STUDENT dialog box will open click Add & Give the inputs & click
UPDATE, repeat this for 2 or 3 inputs. & close the Database Window.
11. Open the design window Select the Data1 Control and change the properties
DatabaseName Select the data base which is saved in My Documents Eg:
STUDENT.mdb & Click OPEN.
12. In Properties select RecordSource & Select the Table Name Eg: STUDENT.
13. Select the Text1 control in the design window and change the properties of
DataSource as Data1 & select the DataField & Select the Attribute Name.
14. Repeat the same process for Text2 & Text3.
OUTPUT

Anda mungkin juga menyukai