Click here to Skip to main content
15,886,258 members
Articles / Programming Languages / Visual Basic
Alternative
Tip/Trick

Call Functions Until One Meets Condition

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
6 Apr 2011CPOL 5.6K   1   1
Sorry, but I don't like adding additional artificial elements like function arrays . I would code it as following:If isok(Step1()) OrElse isok(Step2(1,1)) OrElse isok(Step3() OrElse isok(Step4() OrElse isok(0+1) thenend ifFunction isok(ByVal rc as Integer) As Boolean ...
Sorry, but I don't like adding additional artificial elements like function arrays . I would code it as following:

If isok(Step1()) OrElse
   isok(Step2(1,1)) OrElse
   isok(Step3() OrElse
   isok(Step4() OrElse
   isok(0+1) then
end if

Function isok(ByVal rc as Integer) As Boolean
    if(rc>=5) Return True
    return False
End Function
I think it's less coding and easier to understand.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralSounds like a good alternative to me. Pin
AspDotNetDev6-Apr-11 10:41
protectorAspDotNetDev6-Apr-11 10:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.