Foxtable(狐表)用户栏目专家坐堂 → 求助 分数计算


  共有1802人关注过本帖树形打印复制链接

主题:求助 分数计算

帅哥哟,离线,有人找我吗?
jackyfashion
  1楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:655 积分:5085 威望:0 精华:0 注册:2013/10/7 22:27:00
求助 分数计算  发帖心情 Post By:2018/5/11 21:23:00 [只看该作者]

老师:
您好!
请问点样设置可以像 Excel 的分数计算,比如 : 第三列 = 第一列+第二列   的分数计算
请老师示教!!!
谢谢!!!

图片点击可在新窗口打开查看此主题相关图片如下:333.png
图片点击可在新窗口打开查看



 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106680 积分:542589 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2018/5/11 22:08:00 [只看该作者]

全局代码:
Public Class simplefraction
    ' Methods
    Public Sub New(ByVal num As Integer, ByVal deno As Integer)
        Me._numerator = num
        Me._denominator  = deno
    End Sub

    Public Function Display() As String
        Me.Simplifying
        Return String.Format("{0}/{1}", Me._numerator, Me._denominator )
    End Function

    Public Shared Operator +(ByVal a As simplefraction, ByVal b As simplefraction) As simplefraction
        Return New simplefraction(((a._numerator * b._denominator ) + (b._numerator * a._denominator )), (a._denominator  * b._denominator ))
    End Operator

    Public Shared Operator /(ByVal a As simplefraction, ByVal b As simplefraction) As simplefraction
        Return New simplefraction((a._numerator * b._denominator ), (a._denominator  * b._numerator))
    End Operator

    Public Shared Operator *(ByVal a As simplefraction, ByVal b As simplefraction) As simplefraction
        Return New simplefraction((a._numerator * b._numerator), (a._denominator  * b._denominator ))
    End Operator

    Public Shared Operator -(ByVal a As simplefraction, ByVal b As simplefraction) As simplefraction
        Return New simplefraction(((a._numerator * b._denominator ) - (b._numerator * a._denominator )), (a._denominator  * b._denominator ))
    End Operator

    Private Sub Simplifying()
        Dim turn As Integer = 0
        Dim minus As Boolean = (Me._numerator < 0)
        Me._numerator = Math.Abs(Me._numerator)
        turn = Math.Min(Me._numerator, Me._denominator )
        Do While (turn > 1)
            If (((Me._numerator Mod turn) = 0) AndAlso ((Me._denominator  Mod turn) = 0)) Then
                Me._numerator = (Me._numerator / turn)
                Me._denominator  = (Me._denominator  / turn)
            Else
                turn -= 1
            End If
        Loop
        If minus Then
            Me._numerator = (-1 * Me._numerator)
        End If
    End Sub


    ' Properties
    Public ReadOnly Property Denominator  As String
        Get
            Return Me._denominator .ToString
        End Get
    End Property

    Public ReadOnly Property Numerator As String
        Get
            Return Me._numerator.ToString
        End Get
    End Property


    ' Fields
    Private _denominator  As Integer
    Private _numerator As Integer
End Class

调用

Dim _a As String = "1/2"
Dim _b As String = "1/4"
Dim arr() As String = _a.Split("/")
Dim brr() As String = _b.Split("/")
Dim a As new simplefraction(val(arr(0)), val(arr(1)))
Dim  b As new simplefraction(val(brr(0)), val(brr(1)))
Dim c As simplefraction = a + b
msgbox(c.Display)
c = a - b
msgbox(c.Display)
c = a * b
msgbox(c.Display)
c = a / b
msgbox(c.Display)

 回到顶部
帅哥哟,离线,有人找我吗?
jackyfashion
  3楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:655 积分:5085 威望:0 精华:0 注册:2013/10/7 22:27:00
  发帖心情 Post By:2018/5/11 22:20:00 [只看该作者]

谢谢老师!!!
我还是看不懂.以后看看能不能领悟得到.
谢谢!!!

 回到顶部