注册 登录
Office中国论坛/Access中国论坛 返回首页

todaynew的个人空间 http://www.office-cn.net/?144436 [收藏] [复制] [分享] [RSS]

日志

简单实用的计算器

已有 1491 次阅读2009-3-26 19:39 |个人分类:习作

 
主窗体:
Private Sub 折让_DblClick(Cancel As Integer)
    '请在OpenArgs参数中,用,号分割主窗体、子窗体控件、控件名称
    Dim Ctlname As String
    Ctlname = Screen.ActiveControl.Name
    DoCmd.OpenForm "myCalc", , , , , , Me.Form.Name & "," & Ctlname
End Sub
子窗体:
Private Sub 数量_DblClick(Cancel As Integer)
    '请在OpenArgs参数中,用,号分割主窗体、子窗体控件、控件名称
    Dim Ctlname As String
    Ctlname = Screen.ActiveControl.Name
    DoCmd.OpenForm "myCalc", , , , , , Me.Parent.Form.Name & "," & Me.Form.Name & "," & Ctlname
End Sub
myCalc窗体:
Private Sub 等于_Click()
Dim str As String
Dim Pfname As String
Dim Sfname As String
Dim Cname As String
On Error GoTo 等于_Err
    If IsNull(Me.计算.Value) = False Then
        Me.计算.Value = Eval(Me.计算.Value)
    Else
         Me.计算.SetFocus
        Exit Sub
    End If
    If OpenArgs <> "" Then
        str = OpenArgs
        Pfname = Mid(str, 1, InStr(1, str, ",") - 1)
        str = Replace(str, Pfname & ",", "")
        If InStr(1, str, ",") = 0 Then
            Sfname = Pfname
            Cname = str
            Forms(Sfname).Form.Controls(Cname).Value = Me.计算.Value
        Else
            Sfname = Mid(str, 1, InStr(1, str, ",") - 1)
            str = Replace(str, Sfname & ",", "")
            Cname = str
            Forms(Pfname).Controls(Sfname).Form.Controls(Cname).Value = Me.计算.Value
        End If
        DoCmd.Close acForm, "myCalc"
    End If
等于_Exit:
    Exit Sub
等于_Err:
    Me.计算.Value = "兄弟,搞错了吧?!^o^  "
    Resume 等于_Exit
End Sub
Private Sub L0_Click()
    Me.计算.Value = Me.计算.Value & Me.L0.Caption
End Sub
。。。。。

发表评论 评论 (1 个评论)

回复 tmtony 2009-3-28 14:08
谢谢 分享,收藏了

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-4-28 15:27 , Processed in 0.058462 second(s), 18 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回顶部