I see a FAQ like the following description, but I don't understand the second way. Why he uses DoEvents to get Form number?
-------------
Q:What is the easiest way to find the number of open forms in my app?
A:There are two ways - equally easy. The first is to retrieve the form collection count...
numFormsOpen = Forms.Count
...and the second is to use the DoEvents function!...
numFormsOpen = DoEvents
-------------
Q:What is the easiest way to find the number of open forms in my app?
A:There are two ways - equally easy. The first is to retrieve the form collection count...
numFormsOpen = Forms.Count
...and the second is to use the DoEvents function!...
numFormsOpen = DoEvents
文章標籤
全站熱搜

以下是 Msdn 的說明: DoEvents 函數會傳回一個Integer,以代表 Visual Basic 的單一版本中所開啟的表單個數,例如, Visual Basic專業版。在其它的應用版本中,DoEvents 會傳回 0。 <<VB入門網>>預告: 12/28 http://www.ruentex.com.tw/vbguide 問題207:如何使用 ADO 來壓縮或修復 Microsoft Access 資料庫?
Forms.Count 跟 DoEvents 的意義是不同的。 Forms.Count 傳回的是目前已經載入的 form 的個數。而 DoEvents 傳回的是目前可見 (Visible = True) 的 form 的個數。 除此之外,DoEvents 還有暫時把控制權交還給 OS 的功能。