86% found this document useful (7 votes)
371 views29 pages

VB6 Programs for Calculator and Conversion

The document describes a program to design a currency conversion system using Visual Basic. It uses option buttons and frames to allow the user to select different currencies to convert between. When the user enters an amount in one field and selects the currencies, clicking a button will perform the conversion and display the result. The program contains logic to handle all possible conversion combinations between US Dollars, Indian Rupees, British Pounds, and Euros using appropriate exchange rates.

Uploaded by

Gaurav Saxena
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
86% found this document useful (7 votes)
371 views29 pages

VB6 Programs for Calculator and Conversion

The document describes a program to design a currency conversion system using Visual Basic. It uses option buttons and frames to allow the user to select different currencies to convert between. When the user enters an amount in one field and selects the currencies, clicking a button will perform the conversion and display the result. The program contains logic to handle all possible conversion combinations between US Dollars, Indian Rupees, British Pounds, and Euros using appropriate exchange rates.

Uploaded by

Gaurav Saxena
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Program No.

: - 1
Name: - Gaurav Saxena Roll No. : - 1308727
Class: - MCA (3rd Sem.) Page No. :-_______
Statement: - Write a program to design a calculator using Control Array.

Dim Operand1, Operand2 As Double


Dim Operator As String
Dim ClearDisplay As Boolean
Private Sub ClearBttn_Click()
[Link] = ""
End Sub
Private Sub Digits_Click(Index As Integer)
If ClearDisplay Then
[Link] = ""
ClearDisplay = False
End If
[Link] = [Link] + Digits(Index).Caption
End Sub
Private Sub Div_Click()
Operand1 = Val([Link])
Operator = "/"
[Link] = ""
End Sub
Private Sub DotBttn_Click()
If ClearDisplay Then
[Link] = ""
ClearDisplay = False
End If
If InStr([Link], ".") Then
Exit Sub
Else
[Link] = [Link] + "."
End If
End Sub
Private Sub Minus_Click()
Operand1 = Val([Link])
Operator = "-"
[Link] = ""
End Sub

Private Sub Over_Click()


If Val([Link]) <> 0 Then [Link] = 1 / Val([Link])
End Sub

Private Sub Plus_Click()


Operand1 = Val([Link])
Operator = "+"
[Link] = ""
End Sub

Private Sub PlusMinus_Click()


[Link] = -Val([Link])
End Sub

Private Sub Times_Click()


Operand1 = Val([Link])
Operator = "*"
[Link] = ""
End Sub

INPUT AND OUTPUT:-


Program No. : - 2
Name: - Gaurav Saxena Roll No. : - 1308727
rd
Class: - MCA (3 Sem.) Page No. :-_______
Statement: - Write a Program to design an interface using option buttons & frame control for
Currency Conversion System.

Private Sub Command1_Click()


Dim a As Single, b As Single
a = CSng([Link])
If ([Link] = True) Then
If ([Link] = True) Then
a=a
[Link] = a
Else
If ([Link] = True) Then
b = a / 46
[Link] = b
Else
If ([Link] = True) Then
b = a / 55
[Link] = b
Else
If ([Link] = True) Then
b = a / 70
[Link] = b
End If
End If
End If
End If
End If
If ([Link] = True And [Link] = True) Then
b = a * 46
[Link] = b
End If
If ([Link] = True And [Link] = True) Then
b=a
[Link] = b
End If
If ([Link] = True And [Link] = True) Then
b = a * 1.19
[Link] = b
End If
If ([Link] = True And [Link] = True) Then
b = a * 1.34
[Link] = b
End If
If ([Link] = True And [Link] = True) Then
b = a * 55
[Link] = b
End If
If ([Link] = True And [Link] = True) Then
b = a / 1.19
[Link] = b
End If
If ([Link] = True And [Link] = True) Then
b=a
[Link] = b
End If
If ([Link] = True And [Link] = True) Then
b = a / 1.21
[Link] = b
End If
If ([Link] = True And [Link] = True) Then
b = a * 70
[Link] = b
End If
If ([Link] = True And [Link] = True) Then
b = a * 1.32
[Link] = b
End If
If ([Link] = True And [Link] = True) Then
b = a * 1.21
[Link] = b
End If
If ([Link] = True And [Link] = True) Then
b=a
[Link] = b
End If
End Sub

Private Sub Command2_Click()


[Link] = " "
[Link] = " "
End Sub

Private Sub Command3_Click()


End
End Sub
Output:-
Program No. : - 3
Name: - PANKAJ Roll No. : - 1308755
rd
Class: - MCA (3 Sem.) Page No. :-_______
Statement: - Write a Program to design an interface having two list box and perform the following
operations on the box:-
1. Shift item from one list to another.
2. Shift all items from one list to another.
3. Copy any selected item to another list box.
4. Copy all items to another list box.
5. Drag items from one list box to another.

Private Sub Form_Load()


[Link] "Pascal"
[Link] "Fortran"
[Link] "Basic"
[Link] "C"
[Link] "C++"
[Link] "Visual Basic"
[Link] "Visual C++"
[Link] "Java"
[Link] = "Front End Tools"
[Link] "MS-Access"
[Link] "Oracle"
[Link] "SQL Server"
[Link] "Sybase"
[Link] "Ingres"
[Link] "Unify"
[Link] "IBM DB2"
[Link] "MY SQL"
[Link] = "Back End Tools"
End Sub

Private Sub Combo1_Click()


[Link] [Link]([Link])
End Sub

Private Sub Combo2_Click()


[Link] [Link]([Link])
End Sub

Private Sub Command1_Click()


If [Link] = 0 Then
MsgBox "List Box 1 is Empty"
Exit Sub
End If
If [Link] < 0 Then
MsgBox "Please Select Any Item from List1"
Else
[Link] [Link]([Link])
[Link] [Link]
End If
End Sub

Private Sub Command2_Click()


If [Link] = 0 Then
MsgBox "List Box 1 is Empty"
Exit Sub
End If

While [Link] <> 0


[Link] [Link]([Link](0))
[Link] [Link](0)
Wend
End Sub

Private Sub Command3_Click()


If [Link] = 0 Then
MsgBox "List Box 2 is Empty"
Exit Sub
End If

If [Link] < 0 Then


MsgBox "Please Select Any Item from List2"
Else
[Link] [Link]([Link])
[Link] [Link]
End If
End Sub

Private Sub Command4_Click()


If [Link] = 0 Then
MsgBox "List Box 2 is Empty"
Exit Sub
End If

While [Link] <> 0


[Link] [Link]([Link](0))
[Link] [Link](0)
Wend
End Sub
Output
Program No. : -11
Name: - Gaurav Saxena Roll No. : - 1308727
Output:-
rd
Class: - MCA (3 Sem.) Page No. :-_______
Statement: - Design an application which display following information of a student(using oracle)
like stud_rollno, stud_regno, stud_name, stud_address, stud_contactno, stud_class, marks in 5
different subjects, total and percentage. Also perform following operations using ADODB:
a) Insert a new record.
b) Delete a record.
c) Modify/update a record.
d) Search a record.

Dim cn As [Link]
Dim rs As [Link]
Dim rs1 As [Link]
Private Sub cmdadd_Click()
[Link] = " "
[Link] = " "
[Link] = " "
[Link]
End Sub
Sub display()
[Link] = [Link](0)
[Link] = [Link](1)
[Link] = [Link](2)
End Sub

Private Sub cmddelete_Click()


Dim sql As String
Dim s As Integer
s = InputBox("enter the roll no to be deleted")
sql = "delete from student719 where rollno=" & CInt(s)
[Link] (sql)
MsgBox "1 record deleted"
Call recordset_refresh
End Sub

Private Sub cmdexit_Click()


End
End Sub

Private Sub cmdfirst_Click()


[Link]
Call display
End Sub
Private Sub cmdlast_Click()
[Link]
Call display
End Sub

Private Sub cmdmodify_Click()


Dim i As Integer
i = InputBox("enter the roll no to be deleted")
[Link]
While [Link]
If [Link](0) = i Then
modify1
Exit Sub
End If
[Link]
Wend
End Sub

Private Sub cmdnext_Click()


[Link]
If [Link] Then
[Link]
End If
Call display
End Sub

Private Sub cmdprev_Click()


[Link]
If [Link] Then [Link]
Call display
End Sub

Private Sub cmdsave_Click()


Dim sql As String
sql = "insert into student719 values(" & CInt([Link]) & ",'" & [Link] & "'," &
CSng([Link]) & ")"
[Link] (sql)
MsgBox "1 record created"
Call recordset_refresh
[Link] = " "
[Link] = " "
[Link] = " "
[Link]
End Sub
Private Sub Form_Load()
Set cn = New [Link]
[Link] = "provider=msdaora.1;password=tiger;user id=scott;data
source=oracle"
[Link]
Call recordset_refresh
MsgBox "connection created"
End Sub
Sub recordset_refresh()
Set rs = New [Link]
[Link] "select * from student719", cn, adOpenKeyset, adLockOptimistic
End Sub
Sub modify1()
[Link] = [Link](0)
[Link] = [Link](1)
[Link] = [Link](2)
End Sub

Output:-
Program No. : - 10
Name: - Gaurav Saxena Roll No. : - 1308727
rd
Class: - MCA (3 Sem.) Page No. :-_______
Statement: - : Use DAO(Data Access Object) to connect the applications with database(in MS
ACCESS) named ‘employee’ having table ‘emp_info’ with fields emp_id, emp_name,
basic_salary, house rent allowance, provident fund, dearance allowance, net_salary,tax. Also
performs operations as given below:
a) Insert a new record.
b) Delete a record.
c) Modify/update a record.
d) Move on first, next, previous and last record.

Private Sub Command1_Click()


[Link] = (Val([Link]) + Val([Link]) / 100 + Val([Link]) / 100) -
Val([Link])
[Link] = Val([Link]) * 20 / 100
End Sub

Private Sub Command2_Click()


[Link]
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
End Sub

Private Sub Command3_Click()


[Link]
If [Link] = True Then
[Link]
End If
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
End Sub

Private Sub Command4_Click()


[Link]
If [Link] = True Then
[Link]
End If
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
End Sub

Private Sub Command5_Click()


[Link]
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
End Sub

Private Sub Command6_Click()


[Link]
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
End Sub

Private Sub Command7_Click()


[Link]
MsgBox ("Record Successfully Update")
End Sub

Private Sub Command8_Click()


[Link]
MsgBox ("Record Successfully Deleted")
End Sub

Private Sub Command9_Click()


End
End Sub

Private Sub Command10_Click()


End
End Sub
Output:-
Program No. : - 12
Name: - Gaurav Saxena Roll No. : - 1308727
rd
Class: - MCA (3 Sem.) Page No. :-_______
Statement: - Write a program to create book database and prepare report using Microsoft flex grid
control.

Dim con As [Link]


Dim rs As [Link]

Private Sub Form_Load()


Set cn = New [Link]
Set rs = New [Link]
[Link] = "provider=[Link].4.0;Data Source=d:\[Link]"
[Link]
[Link] "Select * from book1", cn, adOpenStatic, adLockOptimistic
r=1
[Link](0, 1) = "Book Code"
[Link](0, 2) = "Book Name"
[Link](0, 3) = "publisher"
[Link](0, 4) = "Price"
[Link](0, 5) = "Subject"
[Link](0, 6) = "Edition"

While Not [Link]


For f = 0 To 5
[Link](r, f + 1) = [Link](f)
Next
[Link]
r=r+1

Wend
End Sub
OUTPUT:

Form1
Program No. : - 4
Name: - Gaurav Saxena Roll No. : - 1308727
rd
Class: - MCA (3 Sem.) Page No. :-_______
Statement: - Design a notepad applications using common dialog control with complete menus
coding.

Private Sub Command1_Click()


[Link] = "Text files(*.txt)|*.txt"
[Link]
[Link] = [Link]
[Link]
Exit Sub
End Sub

Private Sub Command2_Click()


test = MsgBox("You Really Want To Save File ?", _
vbYesNo + vbQuestion, "Acknowledgement")
If test = vbYes Then
[Link] = "txt"
'[Link] = "Text files(*.txt)|*.txt"
[Link]
[Link] ([Link])
End If
[Link]
End Sub

Private Sub Command3_Click()


[Link] = cdlCFBoth + cdlCFEffects
[Link]
[Link] = [Link]
[Link] = [Link]
[Link] = [Link]
[Link] = [Link]
[Link]
End Sub

Private Sub Command4_Click()


[Link]
[Link] = [Link]
[Link]
End Sub

Private Sub Command5_Click()


Unload Me
End Sub
Private Sub Copy_Click()
[Link] Common_Dialog.[Link]
[Link] = True
End Sub

Private Sub Cut_Click()


[Link] Common_Dialog.[Link]
Common_Dialog.[Link] = ""
[Link] = True
End Sub

Private Sub Exit_Click()


End
End Sub

Private Sub Fomt_Click()


[Link] = cdlCFBoth + cdlCFEffects
[Link]
[Link] = [Link]
[Link] = [Link]
[Link] = [Link]
[Link] = [Link]
[Link]
End Sub

Private Sub Open_Click()


[Link] = "Text files(*.txt)|*.txt"
[Link]
[Link] = [Link]
[Link]
Exit Sub
End Sub

Private Sub Paste_Click()


Common_Dialog.RichTextBox1 = [Link]
End Sub

Private Sub Save_Click()


test = MsgBox("You Really Want To Save File ?", _
vbYesNo + vbQuestion, "Acknowledgement")
If test = vbYes Then
[Link] = "txt"
[Link] = "Text files(*.txt)|*.txt"
[Link]
[Link] ([Link])
End If
[Link]
End Sub

Private Sub Saveas_Click()


[Link]
End Sub

Output
Program No. : - 5
Name: - Gaurav Saxena Roll No. : - 1308727
rd
Class: - MCA (3 Sem.) Page No. :-_______
Statement: - Write a program to demonstrate dynamic menus appearance (i.e. add and remove the
menus at runtime).

Dim rtitems As Variant


Private Sub Command1_Click()
rtitems = rtitems + 1
Load Gaurav(rtitems)
Gaurav(rtitems).Caption = "dynamic menu item#" & Str(rtitems)
End Sub

Private Sub Command2_Click()


If rtitems = 0 Then
MsgBox "menu is already empty"
Else
Unload Gaurav(rtitems)
rtitems = rtitems - 1
End If
End Sub

Private Sub fillmenu()


Dim i As Integer
Call emptymenu
For i = 1 To 3
Load mnufileslist(i)
mnufileslist(i).Caption = "file" & i
Next i
mnufileslist(0).Visible = False
End Sub

Private Sub emptymenu()


Dim i As Integer
mnufileslist(0).Visible = True
For i = 1 To [Link]
Unload mnufileslist(i)
Next i
End Sub

Private Sub exit1_Click()


Unload Me
End Sub
Output:-
Program No. : - 9
Name: - Gaurav Saxena Roll No. : - 1308727
rd
Class: - MCA (3 Sem.) Page No. :-_______
Statement: - Write a program to display date and time in a panel of status bar alternatively with
an interval of 5 seconds using timer control.

Dim a As Integer
Private Sub Form_Load()
[Link] = False
a=0
End Sub

Private Sub Timer1_Timer()


If a <= 5 Then
[Link](1) = Time()
a=a+1
Else

[Link](1) = ""
[Link] = False
a=0
[Link] = True
End If
End Sub

Private Sub Timer2_Timer()


If a <= 5 Then
[Link](2) = Date
a=a+1
Else

[Link](2) = ""
[Link] = True
a=0
[Link] = False
End If
End Sub
Output:-
Program No. : - 6
Name: - Gaurav Saxena Roll No. : - 1308727
Class: - MCA (3rd Sem.) Page No. :-_______
Statement: - Write a program to convert a number into its text form.

Dim a As Double, l As Integer, m As Double


Dim temp As String
Private Sub once(x As Double)
Select Case (x)
Case 1:
ch = "One "
Case 2:
ch = "Two "
Case 3:
ch = "Three "
Case 4:
ch = "Four "
Case 5:
ch = "Five "
Case 6:
ch = "Six "
Case 7:
ch = "Seven "
Case 8:
ch = "Eight "
Case 9:
ch = "Nine "
Case 10:
ch = "Ten "
Case 11:
ch = "Eleven "
Case 12:
ch = "Twelve "
Case 13:
ch = "Thirteen "
Case 14:
ch = "Fourteen "
Case 15:
ch = "Fifteen "
Case 16:
ch = "Sixteen "
Case 17:
ch = "Seventeen "
Case 18:
ch = "Eighteen "
Case 19:
ch = "Nineteen "
End Select
[Link] = [Link] & ch
End Sub

Private Sub tens(x As Double)


Select Case (x)
Case 2:
ch = "Twenty "
Case 3:
ch = "Thirty "
Case 4:
ch = "Fourty "
Case 5:
ch = "Fifty "
Case 6:
ch = "Sixty "
Case 7:
ch = "Seventy "
Case 8:
ch = "Eighty "
Case 9:
ch = "Ninety "
End Select
[Link] = [Link] & ch
End Sub

Private Sub gets(mm As Double)


If mm <= 19 Then
Call once(mm)
Else
Call tens(Mid(mm, 1, 1))
Call once(Mid(mm, 2, 1))
End If
End Sub

Private Sub Command1_Click()


a = [Link]
[Link] = a
l = Len([Link])

If a > 10000000 Then


MsgBox "Please Enter Upto 1 Crore"
[Link] = Empty
[Link] = Empty
Exit Sub
ElseIf a = 10000000 Then
[Link] = "1 Crore"
Exit Sub
End If

abc:
Select Case (l)
Case 7:
m = Left(a, 2)
gets (m)
message (6)
a = Mid(a, 3, 5)
temp = a
l = Len(temp)
GoTo abc

Case 6:
Call once(Left(a, 1))
message (6)
a = Mid(a, 2, 5)
temp = a
l = Len(temp)
GoTo abc

Case 5:
m = Left(a, 2)
gets (m)
message (4)
a = Mid(a, 3, 3)
temp = a
l = Len(temp)
GoTo abc

Case 4:
Call once(Left(a, 1))
message (4)
a = Mid(a, 2, 3)
temp = a
l = Len(temp)
GoTo abc

Case 3:
Call once(Left(a, 1))
Call message(3)
m = Mid(a, 2, 2)
gets (m)

Case 2:
gets (a)

Case 1:
Call once(a)
End Select
End Sub

Private Sub message(i As Integer)


Select Case (i)
Case 6:
[Link] = [Link] & "Lakhs "
Case 4:
[Link] = [Link] & "Thousand "
Case 3:
[Link] = [Link] & "Hundred "
End Select
End Sub

Private Sub Command2_Click()


[Link] = Empty
[Link] = Empty
[Link]
End Sub
Output:-

You might also like