Foxtable(狐表)用户栏目专家坐堂 → 求助 全局代码


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

主题:求助 全局代码

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


加好友 发短信
等级:三尾狐 帖子:668 积分:5190 威望:0 精华:0 注册:2013/10/7 22:27:00
求助 全局代码  发帖心情 Post By:2018/6/3 12:51:00 [显示全部帖子]

老师:
您好!
我想把英吋转厘米我代码写在全局代码内,窗口Button的代码如下:

Public amcm As String

Public cmovrnd As Decimal

If amcm.Contains(" ") = False AndAlso amcm.Contains("/") Then

    Public slam() As String = amcm.split("/")

    Public ihcam As Decimal = CSng(slam(0))

    Public ihdam As Decimal = CSng(slam(1))

    Public ihaam As Decimal = ihcam / ihdam

    cmovrnd = Format(Eval(ihaam * 2.54,e.DataRow),"###0.###")

Else

    Public sam() As String = amcm.split(" ")

    Public iham As Decimal = CDec(sam(0))

    If sam.Length = 1 Then

        cmovrnd = Format(Eval(iham * 2.54,e.DataRow),"###0.###")

    Else

        Public slam() As String = sam(1).split("/")

        Public ihcam As Decimal = CSng(slam(0))

        Public ihdam As Decimal = CSng(slam(1))

        Public ihaam As Decimal = ihcam / ihdam

        cmovrnd = Format(Eval((iham + ihaam) * 2.54,e.DataRow),"###0.###")

    End If

End If

厘米转英吋

表事件DataColChanging代码:如下:

Public cmam As Decimal

Public amovrnd As String

                         z =  cmam

                    If z > "" Then

                        Dim s() As String = z.split(".")

                        If s.Length = 1 Then

                            amovrnd = (s(0))

                        Else

                            Dim i As Long = CInt(s(1))

                            Dim j As Long  = 10 ^ s(1).Length

                            Dim k = j *1000 / 16

                            Dim l = i*1000\k

                            If l = 0 Then

                                amovrnd = (s(0))

                            Else

                                Dim m = l / 16

                                Dim d As Decimal = m

                                Dim sl() As String = d.ToString().split(".")

                                If sl.Length = 1 Then

                                   amovrnd = (sl(0))

                                Else

                                    Dim b As Long = CInt(sl(1))

                                    Dim a As Long  = 10 ^ sl(1).Length

                                    Dim c As Long  = a Mod b

                                    Dim x = a

                                    Dim y = b

                                    Do While c <> 0

                                        a=b

                                        b=c

                                        c = a Mod b

                                    Loop

                                    Dim r As String

                                    If (s(0)) = 0  Then

                                        r = y/b & "/" & x/b

                                    Else

                                        r = s(0) &" " & y/b & "/" & x/b

                                    End If

                                    amovrnd = (r)

                                End If

                            End If

                        End If

                    End If

            End Select

               Select Case e.DataCol.name

            Case "siudamkf"

                Dim z As String

                z =  e.NewValue

                If z > "" Then

                    Dim s() As String = z.split(".")

                    If s.Length = 1 Then

                        e.NewValue = (s(0))

                    Else

                        Dim i As Long = CInt(s(1))

                        Dim j As Long  = 10 ^ s(1).Length

                        Dim k = j *1000 / 16

                        Dim l = i*1000\k

                        If l = 0 Then

                            e.NewValue = (s(0))

                        Else

                            Dim m As String = l / 32

                            Dim d As Decimal = m

                            Dim sl() As String = d.ToString().split(".")

                            If sl.Length = 1 Then

                                e.NewValue = (sl(0))

                            Else

                                Dim b As Long = CInt(sl(1))

                                Dim a As Long  = 10 ^ sl(1).Length

                                Dim c As Long  = a Mod b

                                Dim x = a

                                Dim y = b

                                Do While c <> 0

                                    a=b

                                    b=c

                                    c = a Mod b

                                Loop

                                Dim r As String

                                If (s(0)) = 0  Then

                                    r = y/b & "/" & x/b

                                Else

                                    r = s(0) &" " & y/b & "/" & x/b

                                End If

                                e.NewValue = (r)

                            End If

                        End If

                    End If

                End If

        End Select

    End If

  请老师指教!

谢谢老师!!!


[此贴子已经被作者于2018/6/3 13:06:18编辑过]

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


加好友 发短信
等级:三尾狐 帖子:668 积分:5190 威望:0 精华:0 注册:2013/10/7 22:27:00
  发帖心情 Post By:2018/6/3 13:18:00 [显示全部帖子]

老师:
您 好!
我真是不懂得怎样写代码在全局代码,现在开始学习全局代码,
求老师帮一下忙,事后我在领会,看能不能理解全局代码
谢谢老师的教导!!!
谢谢!

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


加好友 发短信
等级:三尾狐 帖子:668 积分:5190 威望:0 精华:0 注册:2013/10/7 22:27:00
  发帖心情 Post By:2018/6/3 18:39:00 [显示全部帖子]

谢谢老师!
谢谢!!!

 回到顶部