zoukankan      html  css  js  c++  java
  • VB操作Excel无法更新的问题研究(续)

    初步找到问题所在,是因为使用了form.hide而不是unload form。也就是隐藏窗体还是关闭窗体,导致了数据更新问题。

    You can hide a form so that it is not visible to a user. When the form is hidden, the user cannot interact with the form, but you still have full programmatic control of them.

    To hide a form

    Use the Hide method.
    For example, in the code associated with the Click event of a command button, you could include the following line of code:

    THISFORM.Hide

    When the user clicks the command button, the form remains in memory, but is not visible.

    Releasing a Form
    You can allow a user to release a form when he or she is finished interacting with it. When you release a form, you can no longer access properties and methods of the form.

    To release a form

    Call the Release method.
    For example, in the code associated with the Click event of a command button, you could include the following line of code:

    THISFORM.Release

    When the user clicks the command button, the form closes.

    Unload Forms

    This will unload all forms in memory before the calling form is unloaded. Not only does this unload each form, it also fires each form's unload event, allowing for a more thorough clean up. Since this is placed in the Query_Unload event, errors can be handled and decisions can be made if the unloading should continue. This is especially useful when using other third-party controls such as the splitter control.

    Place the following code in your main form's Query_Unload event.

     
    Dim f As Form

    For Each f In Forms
        If f.hwnd <> Me.hwnd Then
            Unload f
        End If
    Next

  • 相关阅读:
    二进制安全的一些基础知识
    栈溢出笔记-第五天
    一次基于白盒的渗透测试
    栈溢出笔记-第四天
    Hadoop1-认识Hadoop大数据处理架构
    Kubernetes1-K8s的简单介绍
    Docker1 架构原理及简单使用
    了解使用wireshark抓包工具
    Linux系统设置开机自动运行脚本的方法
    Mariadb/Mysql 主主复制架构
  • 原文地址:https://www.cnblogs.com/ainima/p/6331527.html
Copyright © 2011-2022 走看看