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

  • 相关阅读:
    无限维
    黎曼流形
    why we need virtual key word
    TOJ 4119 Split Equally
    TOJ 4003 Next Permutation
    TOJ 4002 Palindrome Generator
    TOJ 2749 Absent Substrings
    TOJ 2641 Gene
    TOJ 2861 Octal Fractions
    TOJ 4394 Rebuild Road
  • 原文地址:https://www.cnblogs.com/ainima/p/6331527.html
Copyright © 2011-2022 走看看