Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A pesky syntax error when calling a 'null' function 3

Status
Not open for further replies.

JPJeffery

Technical User
May 26, 2006
600
GB
I have a 'While Not' loop in a script which was working fine until I added the following lines within the WHILE loop:
Code:
    If bAppExists = FALSE then
      DoNothing()
    End If

'  (Some other stuff here to do if bAppExists = TRUE)
   ...

    Function DoNothing()
    ' No, really, do nothing at all
    End Function()

Now, I'd have thought it was a fairly reasonable alternative to the BATCH file equivalent of doing a GOTO to a label with nothing underneath it but it doesn't seem to like the 'Function DoNothing' line as that's where the error points to.

So, is it the case that you can't use a Function within a While loop?

Or is it the case you can't define a function with no arguments (which seems absurd to me)?

Or is there another way to achive what I'm doing here without putting the other (unquoted) lines of code (which are IF THEN ELSE based) within the 'If bAppExists = ' loop by making it test for a true condition? I'm trying to avoid nested IFs...

JJ
 
I think I would need to see more of your code to give you a definitive answer, but I don't think the way you are approaching this is the best. If you want to only do things if the app exists, and you want to avoid nested Ifs (which I don't really see a reason to avoid), then you could put the things to do in a Sub and call that sub with an If statement.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
There's no need to call anything in your If block...

If bAppExists = FALSE Then
'do nothing
Else
'your other stuff goes here
End If
 
Make sure your DoNothing function is not contained within the while loop. Also rjoubert's solution is best.
 

EBGreen : Well, I've ended up nesting IFs anyway, but I prefer to avoid it to make the code easier to read.

rjoubert : D'Oh!

:)

alexander1113 : But why?

JJ
 
rjoubert - actually, not D'Oh! at all. The reason I wanted to goto a SUB or FUNCTION is to avoid nesting the rest of the WHILE loop within an IF...THEN...ELSE construct but I don't think it's avoidable, or at least not worth avoiding.

Still, I like your idea anyway...

JJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top