65.9K
CodeProject 正在变化。 阅读更多。
Home

计算器

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.47/5 (17投票s)

2007年7月21日

CPOL

1分钟阅读

viewsIcon

45802

downloadIcon

1896

计算器添加了新功能,现在包含货币转换器

引言

我从 05 年开始开发程序

我 11 岁

Calculator _10_DEMO_23-7-07_updated_.zip 文件包含一个货币转换器,它使用谷歌搜索来转换货币

所以请不要介意我糟糕的英语



我没有解释代码



所以尝试开发一个类似程序并发送到 r.anshul@gmail.com

背景和功能

1. 菜单栏中的日期和时间
2. 单位转换器(在“查看”-->“转换器”中)
3. 温度转换器(在“查看”-->“温度转换器”中)
4. 面积和体积计算器(在“查看”菜单中)
5. 分数到小数和分数简化器(在“查看”-->“分数”中)
6. 最大公约数 (HCF) 或最大公因数 (GCD) 计算器
7. 最小公倍数 (LCM) 计算器
8. 操作演示
9. 上次输入的数字
10. PI 插入

如果您有任何改进建议,请给我发邮件
使用代码


使用代码

正如我在简介中已经提到的,尝试自己编程。 如果您想要代码,请给我发邮件。 r.anshul@gmail.com
// 
 (rad * math.pi) / 180
// 

这是弧度到角度的转换

分数代码

它们经过了充分的测试

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





关注点

转换、面积、体积等

历史

计算器 1.0
© . All rights reserved.