Make select case using the IsLoaded function?

N

Nugimac

I have the following code in the OnCurrent and a cmdClose button click event
of a form called from 3 different forms.

‘*** code start
If IsLoaded(“frmAâ€) then
‘code here to do stuff
End if

If IsLoaded(“frmBâ€) then
‘code here to do stuff
End if

If IsLoaded(“frmCâ€) then
‘code here to do stuff
End if
‘***code end

I would like to change this into a select case statement like:
Select case “IsLoaded…â€
Case “frmAâ€
‘code to do stuff

Case “frmBâ€
‘code to do stuff

Case “frmCâ€
‘code to do stuff
End select

can you please help?
Thanks in advance
 
T

tina

sorry, that won't work. the name of the form is the value inserted in the
IsLoaded() function's argument, but the function only runs once, at the
beginning of the statement, *not* once for each case. a Select Case
statement takes the value of its' argument (in this case, the return value
of the IsLoaded() function) and compares it with each specified case,
looking for a match. since the return value of the IsLoaded() function is
boolean True/False, the only specified cases that apply are True and False.

if only one of the named forms will be open at any given time, you can
shorten the code execution by using ElseIf, rather than separate If
statements, as

If IsLoaded("frmA") Then
'some code
ElseIf IsLoaded("frmB") Then
'some code
ElseIf...

End If

hth
 
G

Guest

Select Case True
case IsLoaded("frmA")
'code to do stuff
case IsLoaded("frmB")
'code to do stuff
case IsLoaded("frmC")
'code to do stuff
End Select

Unlike languages where a case statement is a simple jump statement,
in BASIC, the jump 'labels' are expressions which are evaluated at
runtime.


(david)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top