Jen53403
Programmer
- Jul 17, 2006
- 22
Hi, I'm just learning VB, and I'm coding an Excel add-in using VSTO. I'm trying to show a form, wait for the user to click OK on the form so it unloads, then continue execution from the function that called the form. I did some searching and found the following code which is supposed to accomplish that, but Visual Studio gives me the error that Forms and DoEvents() are not declared. Is there a namespace I'm missing for these? Or is there another solution to my problem? I'm using VB version 2005. Thanks!!
Code:
Public Sub WaitOnFormUnload(ByRef formName As String)
Dim bIsLoaded As Boolean
Dim I As Long
bIsLoaded = True
Do While bIsLoaded = True
bIsLoaded = False
For I = 0 To Forms.Count - 1
If Forms(I).Name = formName Then
bIsLoaded = True
DoEvents()
Exit For ' breaks the for loop
End If
Next I
Loop
End Sub