1

ライブデータフィードを取り込むVBAforExcelで記述されたアプリケーションがあります。データに変更があるたびに、VBA内でさまざまなイベントがトリガーされます。

また、ComboBoxを含むいくつかのユーザーフォームがあります。私の問題は、ComboBoxの下矢印をクリックして選択しようとすると、データフィードから更新を取得した瞬間に、ComboBoxがリセットされることです。私がやりたいのは、ComboBoxで選択を行っている間はイベントを一時停止し、完了したら一時停止を解除することです。この機能を生成するにはどうすればよいですか?

4

3 に答える 3

3

これをオフにしてみてください:

application.enableevents = false

そして、これをオンに戻します:

application.enableevents = true

于 2010-01-12T23:08:39.363 に答える
2

一時停止してメッセージを表示し、一時停止中に何か作業を続けること。最後にボタンを押す

Public Ready As Boolean

Private Sub Command1_Click()
Ready = True
End Sub

Private Sub Form_Load()
Me.Show
Ready = False
Call Wait
Label1.Visible = True
End Sub

Public Function Wait()
Do While Ready = False
    DoEvents
Loop
End Function
于 2011-04-18T03:44:43.320 に答える
1

おそらく、選択が行われるまで、コンボボックスの更新イベントをバイパスするフラグを立てることができます。

Private bLock as boolean  ' declare at module level

' When a user clicks on the combobox
Private Sub DropDownArrow_Click()  ' or cboComboBox_Click()
    bLocked = True
End Sub

' This procedure is the one that does the updating from the data source.
' If the flag is set, do not touch the comboboxes.
Private Sub subUpdateComboBoxes()
    If Not bLocked then
        ' Update the comboboxes
    End If
End Sub


' When the selection is made, or the focus changes from the combobox.
' check if a selection is made and reset the flag.
Private Sub cboComboBox_AfterUpdate()  ' Or LostFucus or something else
    if Format(cboComboBox.Value) <> vbNullString Then
        bLocked = False
    End If
End Sub

それが役立つことを願っています。

于 2010-01-14T20:13:09.197 に答える