设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1994|回复: 2
打印 上一主题 下一主题

[模块/函数] 求助!加入函数 的优化方法(照搬红尘如烟版主的代码出错)谢谢!!

[复制链接]
跳转到指定楼层
1#
发表于 2010-3-28 14:14:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
原程序如下:
Private Sub qxz01_MouseMove(button As Integer, Shift As Integer, x As Single, y As Single)
Call zxzhiduanppp(Me, Me.qxz01)
End Sub
Private Sub qxz02_MouseMove(button As Integer, Shift As Integer, x As Single, y As Single)
Call zxzhiduanppp(Me, Me.qxz02)
End Sub
Private Sub qxz03_MouseMove(button As Integer, Shift As Integer, x As Single, y As Single)
Call zxzhiduanppp(Me, Me.qxz03)
End Sub
Private Sub qxz04_MouseMove(button As Integer, Shift As Integer, x As Single, y As Single)
Call zxzhiduanppp(Me, Me.qxz04)
End Sub
Private Sub qxz05_MouseMove(button As Integer, Shift As Integer, x As Single, y As Single)
Call zxzhiduanppp(Me, Me.qxz05)
End Sub
以上程序是每当鼠标移动到一个字段后 所触发的过程,


我想把以上代码优化成以下函数,就不必在每一个字中加入移动事件了

以下是照搬“红尘如因”版主的代码,可是运行不了,老是出错,报类型不对。

代码如下:
Private Function ButtonEffectInit(Formolll As Form)
    On Error Resume Next
    Dim ctl As Control

    For Each ctl In Formolll

If ctl.ControlType = acCheckBox Then
    If Left(ctl.Name, 3) = "qxz" Then

    ctl.OnMouseMove = "= zxzhiduanppp([" & Formolll & " ], [ " & ctl & " ])"    这里老出错,运行不了

End If
End If
Next
End Function

我想这样写了后,就不用每个字段都去写一个移动事件如:
Private Sub qxz03_MouseMove(button As Integer, Shift As Integer, x As Single, y As Single)
Call zxzhiduanppp(Me, Me.qxz03)
End Sub

我想在 窗体的加载事件中
Private Sub Form_Load()
    Call ButtonEffectInit(Me)
End Sub
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅

点击这里给我发消息

2#
发表于 2010-3-29 00:06:33 | 只看该作者
ctl.OnMouseMove = "= zxzhiduanppp([" & Formolll & " ], [ " & ctl & " ])"    这里老出错,运行不了
试试:
ctl.OnMouseMove = "= zxzhiduanppp([" & Formolll.Name & " ], [ " & ctl.Name & " ])"
3#
 楼主| 发表于 2010-3-30 00:14:06 | 只看该作者
本帖最后由 sxb2007 于 2010-3-30 00:20 编辑

感谢小宝版主的回复,谢谢!但是还是没有解决问题,我把附件发上来了,麻烦您帮我看看好吗?谢谢了!!!
http://www.office-cn.net/forum.php?mod=viewthread&tid=81633&extra=
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-18 06:15 , Processed in 0.085540 second(s), 26 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表