12,889,448 members (47,604 online)
Add your own
alternative version

#### Stats

33.2K views
1.6K downloads
22 bookmarked
Posted 20 Jul 2007

# Calculator

, 22 Aug 2007 CPOL
 Rate this:
Please Sign up or sign in to vote.
New functions added to the calculator , Now currency converter included

## Introduction

I have been developing programs since 05

I am 11 yrs old

Calculator _10_DEMO_23-7-07_updated_.zip file includes a currency converter which uses google search to convert currencies

So donot mind my wrong english

I haven't explained the code

So try to develop a program like this and mail to r.anshul@gmail.com

## Background and Features

1.Date and time in Menubar
2.Unit Converter ( In View --> Converter)
3.Temperature Converter ( In View --> Temperature Converter)
4.Area and Volume Finder( In View Menu)
5.Fraction To Decimal and Fraction Simplifier ( In View --> Fractions)
6.HCF or GCD Finder
7.LCM Finder
8.Operation Shower
9.Last Entered Number
10.PI Insertion

Please mail me if there are any other suggestions to improve it
Using the code

## Using the code

As I have already told in the intro , Try to program by yourselves . If you want the code , mail me . r.anshul@gmail.com
//
(rad * math.pi) / 180
//

this is the rad to deg conversion

Fraction codes

They are well tested

Function dec2frac(ByVal dblDecimal As Double) As String

Dim intNumerator, intDenominator, intNegative As Integer

Dim dblFraction, dblAccuracy As Double

Dim txtDecimal As String

dblAccuracy = 0.1                                       ' Set the initial Accuracy level.

txtDecimal = dblDecimal.ToString                        ' Get a  string representation of the input number.

For i As Integer = 0 To (txtDecimal.Length - 1)                                 ' Check each character to see if it's a decimal point...

If txtDecimal.Substring(i, 1) = "." Then                    ' if it is then we get the number of digits behind the decimal

dblAccuracy = 1 / 10 ^ (txtDecimal.Length - i)    '   assign the new accuracy level, and

Exit For                                            '   exit the for loop.

End If

Next

intNumerator = 0                                ' Set the initial numerator value to 0.

intDenominator = 1                              ' Set the initial denominator value to 1.

intNegative = 1                                 ' Set the negative value flag to positive.

If dblDecimal < 0 Then

intNegative = -1 ' If the desired decimal value is negative,

End If

dblFraction = 0                                 ' Set the fraction value to be 0/1.

Do While Math.Abs(dblFraction - dblDecimal) > dblAccuracy   ' As long as we're still outside the

'   desired accuracy, then...

If Math.Abs(dblFraction) > Math.Abs(dblDecimal) Then      ' If our fraction is too big,

intDenominator += 1         '   increase the denominator

Else                                            ' Otherwise

intNumerator += intNegative   '   increase the numerator.

End If

dblFraction = intNumerator / intDenominator     ' Set the new value of the fraction.

Loop

Return intNumerator.ToString & "/" & intDenominator.ToString ' Display the numerator and denominator

End Function
Function num(ByVal dblDecimal As Double) As String

Dim intNumerator, intDenominator, intNegative As Integer

Dim dblFraction, dblAccuracy As Double

Dim txtDecimal As String

dblAccuracy = 0.1                                       ' Set the initial Accuracy level.

txtDecimal = dblDecimal.ToString                        ' Get a  string representation of the input number.

For i As Integer = 0 To (txtDecimal.Length - 1)                                 ' Check each character to see if it's a decimal point...

If txtDecimal.Substring(i, 1) = "." Then                    ' if it is then we get the number of digits behind the decimal

dblAccuracy = 1 / 10 ^ (txtDecimal.Length - i)    '   assign the new accuracy level, and

Exit For                                            '   exit the for loop.

End If

Next

intNumerator = 0                                ' Set the initial numerator value to 0.

intDenominator = 1                              ' Set the initial denominator value to 1.

intNegative = 1                                 ' Set the negative value flag to positive.

If dblDecimal < 0 Then

intNegative = -1 ' If the desired decimal value is negative,

End If

dblFraction = 0                                 ' Set the fraction value to be 0/1.

Do While Math.Abs(dblFraction - dblDecimal) > dblAccuracy   ' As long as we're still outside the

'   desired accuracy, then...

If Math.Abs(dblFraction) > Math.Abs(dblDecimal) Then      ' If our fraction is too big,

intDenominator += 1         '   increase the denominator

Else                                            ' Otherwise

intNumerator += intNegative   '   increase the numerator.

End If

dblFraction = intNumerator / intDenominator     ' Set the new value of the fraction.

Loop

Return intNumerator.ToString

End Function
Function den(ByVal dblDecimal As Double) As String

Dim intNumerator, intDenominator, intNegative As Integer

Dim dblFraction, dblAccuracy As Double

Dim txtDecimal As String

dblAccuracy = 0.1                                       ' Set the initial Accuracy level.

txtDecimal = dblDecimal.ToString                        ' Get a  string representation of the input number.

For i As Integer = 0 To (txtDecimal.Length - 1)                                 ' Check each character to see if it's a decimal point...

If txtDecimal.Substring(i, 1) = "." Then                    ' if it is then we get the number of digits behind the decimal

dblAccuracy = 1 / 10 ^ (txtDecimal.Length - i)    '   assign the new accuracy level, and

Exit For                                            '   exit the for loop.

End If

Next

intNumerator = 0                                ' Set the initial numerator value to 0.

intDenominator = 1                              ' Set the initial denominator value to 1.

intNegative = 1                                 ' Set the negative value flag to positive.

If dblDecimal < 0 Then

intNegative = -1 ' If the desired decimal value is negative,

End If

dblFraction = 0                                 ' Set the fraction value to be 0/1.

Do While Math.Abs(dblFraction - dblDecimal) > dblAccuracy   ' As long as we're still outside the

'   desired accuracy, then...

If Math.Abs(dblFraction) > Math.Abs(dblDecimal) Then      ' If our fraction is too big,

intDenominator += 1         '   increase the denominator

Else                                            ' Otherwise

intNumerator += intNegative   '   increase the numerator.

End If

dblFraction = intNumerator / intDenominator     ' Set the new value of the fraction.

Loop

Return intDenominator.ToString

End Function

## Points of Interest

CONVERSIONS , AREAS , VOLUMES etc

Calculator 1.0

## License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

## About the Author

 Student India
No Biography provided

## Comments and Discussions

 First Prev Next
 My vote of 3 Member 1000433528-Apr-13 0:25 Member 10004335 28-Apr-13 0:25
 My vote of 5 kunal paliwal2-Oct-11 21:24 kunal paliwal 2-Oct-11 21:24
 version 1 mark saunders21-Jul-07 1:55 mark saunders 21-Jul-07 1:55
 Nice version 1 well done!! the best way to learn is do, currency conversion from a web service would be a good feature. http://www.webservicex.net/WS/WSDetails.aspx?CATID=2&WSID=10
 Re: version 1 pranav9522-Jul-07 3:15 pranav95 22-Jul-07 3:15
 Re: version 1 pranav9523-Jul-07 2:01 pranav95 23-Jul-07 2:01
 Re: version 1 mark saunders23-Jul-07 9:45 mark saunders 23-Jul-07 9:45
 Last Visit: 31-Dec-99 18:00     Last Update: 26-Apr-17 8:14 Refresh 1

General    News    Suggestion    Question    Bug    Answer    Joke    Praise    Rant    Admin

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170424.1 | Last Updated 22 Aug 2007
Article Copyright 2007 by Anshul R
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid