广告合作
  • 今日头条

    今日头条

  • 百度一下

    百度一下,你就知道

  • 新浪网

    新浪网 - 提供新闻线索,重大新闻爆料

  • 搜狐

    搜狐

  • 豆瓣

    豆瓣

  • 百度贴吧

    百度贴吧——全球领先的中文社区

  • 首页 尚未审核订阅工具 订阅

    怎样使用VBA让窗体在指定时间逐渐退出?

    来源:网络收集  点击:  时间:2024-02-29
    【导读】:
    随着手机里面功能越来越丰富,让我们使用起来越来越方便了,给我们的生活带来了极大的便利。怎样使用VBA让窗体在指定时间逐渐退出?工具/原料more手机方法/步骤1/5分步阅读

    首先在开发工具中打开VBA编辑器

    2/5

    在单元格区域当中输入一些内容作为例子

    3/5

    在VBA编辑器中插入模块

    4/5

    在模块当中输入如下代码,然后运行

    Private Declare Function SetLayeredWindowAttributes Lib use32 (ByValhWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags AsLong) As LongPrivate Declare Function GetWindowLong Lib use32 AliasGetWindowLongA (ByVal hWnd As Long, ByVal nIndex As Long) As LongPrivate Declare Function FindWindow Lib use32 Alias FindWindowA(ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function SetWindowLong Lib use32 AliasSetWindowLongA (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLongAs Long) As Long Private Declare Function DrawMenuBar Lib use32 (ByVal hWnd As Long) As Long Private Declare Function SetFocus Lib use32 (ByVal hWnd As Long) As Long Private Declare Sub Sleep Lib kernel32 (ByVal dwMilliseconds As Long) Const WS_EX_LAYERED=H80000 Const GWL_EXSTYLE=(-20) Const LWA_ALPHA=H2 Private Sub UserForm_activate() Application.Wait Now+TimeValue(00:00:05) 激活窗体5秒钟后开始执行下一句代码 Dim xl As Long hWndForm=FindWindow(ThunderDFrame, Me.Caption) Dim rtn As Long rtn=GetWindowLong(hWndForm, GWL_EXSTYLE) rtn=rtn Or WS_EX_LAYERED SetWindowLong hWndForm, GWL_EXSTYLE, rtn For i=255 To 0 Step-5 此句控制速度,值越小速度越快 SetLayeredWindowAttributes hWndForm, 0, i, LWA_ALPHA Sleep 10 DoEvents DrawMenuBar hWndForm

    SetFocus hWndForm Next i Unload Me 关闭窗体 End Sub

    5/5

    用快捷键F5运行窗体,窗体在5秒钟后关闭,且关闭时有过渡效果

    注意事项

    智能手机助理给我们的生活带来了极大的便利!

    本文关键词:

    版权声明:

    1、本文系转载,版权归原作者所有,旨在传递信息,不代表看本站的观点和立场。

    2、本站仅提供信息发布平台,不承担相关法律责任。

    3、若侵犯您的版权或隐私,请联系本站管理员删除。

    4、文章链接:http://www.1haoku.cn/art_177634.html

    相关资讯

    ©2019-2020 http://www.1haoku.cn/ 国ICP备20009186号05-05 19:33:39  耗时:0.034
    0.0336s