Click to See Complete Forum and Search --> : EXIT IF
Roland Siegert
03-15-2000, 12:38 AM
Hi folks,
what I'd like to see in VB7 is "EXIT IF".
So far we've got EXIT DO, EXIT SUB, EXIT FUNCTION, EXIT FOR and EXIT
PROPERTY. However, there is no way to directly step out of an IF-clause.
How about that?
IF fVB7 Then
MsgBox "Yes, I love my VB7"
If Date < #01/01/2001# Then Exit If
MsgBox "And it's finally here"
' Do some more stuff here
Else
' Do some other stuff here
End If
' Continue here after Exit If
What do you think about that suggestion?
CU
Roland
Anthony Verna
03-15-2000, 09:25 AM
C and C++ both do that with "break." However, ask four people how it works,
and you may or may not get 4 different answers. I'm thinking that may not
be the best keyword to add.
"Roland Siegert" <rolenews@deutsche-software.de> wrote:
>Hi folks,
>what I'd like to see in VB7 is "EXIT IF".
>So far we've got EXIT DO, EXIT SUB, EXIT FUNCTION, EXIT FOR and EXIT
>PROPERTY. However, there is no way to directly step out of an IF-clause.
>
>How about that?
>
>IF fVB7 Then
> MsgBox "Yes, I love my VB7"
> If Date < #01/01/2001# Then Exit If
> MsgBox "And it's finally here"
> ' Do some more stuff here
>Else
> ' Do some other stuff here
>End If
>' Continue here after Exit If
>
>What do you think about that suggestion?
>
>CU
>Roland
>
>
Jayesh Jariwala
03-15-2000, 07:59 PM
I also wish to have "continue;" in for...Next similar to one in C/C++
Nowadays to work around nested and ugly if...tyen...else, I use do...Lopp
while (false)
valid_1 = True
valid_2 = False
valid_3 = True
Do
If Not (valid_1) Then Exit Do
If (valid_2) Then Exit Do
If Not (valid_3) Then Exit Do
Loop While (False) '---so that it executes only once.
"Anthony Verna" <averna@strohlsystems.com> wrote:
>
>C and C++ both do that with "break." However, ask four people how it works,
>and you may or may not get 4 different answers. I'm thinking that may not
>be the best keyword to add.
>
>
>
>"Roland Siegert" <rolenews@deutsche-software.de> wrote:
>>Hi folks,
>>what I'd like to see in VB7 is "EXIT IF".
>>So far we've got EXIT DO, EXIT SUB, EXIT FUNCTION, EXIT FOR and EXIT
>>PROPERTY. However, there is no way to directly step out of an IF-clause.
>>
>>How about that?
>>
>>IF fVB7 Then
>> MsgBox "Yes, I love my VB7"
>> If Date < #01/01/2001# Then Exit If
>> MsgBox "And it's finally here"
>> ' Do some more stuff here
>>Else
>> ' Do some other stuff here
>>End If
>>' Continue here after Exit If
>>
>>What do you think about that suggestion?
>>
>>CU
>>Roland
>>
>>
>
Colin McGuigan
03-15-2000, 08:50 PM
Jayesh Jariwala wrote in message <38d023f9$1@news.devx.com>...
>
>I also wish to have "continue;" in for...Next similar to one in C/C++
>
>
>Nowadays to work around nested and ugly if...tyen...else, I use do...Lopp
>while (false)
>
>
> valid_1 = True
> valid_2 = False
> valid_3 = True
>
> Do
>
> If Not (valid_1) Then Exit Do
> If (valid_2) Then Exit Do
> If Not (valid_3) Then Exit Do
>
>
> Loop While (False) '---so that it executes only once.
If you make the assumption that the code can't be redesigned to eliminate
the problem altogether...why don't you just use a GoTo? I mean, it's what
you're doing, really, and using the Do...Loop (False) only obfuscates the
intent, IMHO.
--
Colin McGuigan
Tom Barnaby
03-15-2000, 09:29 PM
"Colin McGuigan" <colin@chicor.com> wrote:
>Jayesh Jariwala wrote in message <38d023f9$1@news.devx.com>...
>>
>>I also wish to have "continue;" in for...Next similar to one in C/C++
>>
>>
>>Nowadays to work around nested and ugly if...tyen...else, I use do...Lopp
>>while (false)
>>
>>
>> valid_1 = True
>> valid_2 = False
>> valid_3 = True
>>
>> Do
>>
>> If Not (valid_1) Then Exit Do
>> If (valid_2) Then Exit Do
>> If Not (valid_3) Then Exit Do
>>
>>
>> Loop While (False) '---so that it executes only once.
>
>
>If you make the assumption that the code can't be redesigned to eliminate
>the problem altogether...why don't you just use a GoTo? I mean, it's what
>you're doing, really, and using the Do...Loop (False) only obfuscates the
>intent, IMHO.
>
>
>--
>Colin McGuigan
>
>
>
Haven't you heard Colin? GoTos are the work of Satan.
Tom Barnaby
03-15-2000, 09:32 PM
"Jayesh Jariwala" <jariwala_jayesh@hotmail.com> wrote:
I agree completely! Would very much like a continue key word. ****, even
the Unix Bourne script language has a continue command.
>
>I also wish to have "continue;" in for...Next similar to one in C/C++
>
>
>Nowadays to work around nested and ugly if...tyen...else, I use do...Lopp
>while (false)
>
>
> valid_1 = True
> valid_2 = False
> valid_3 = True
>
> Do
>
> If Not (valid_1) Then Exit Do
> If (valid_2) Then Exit Do
> If Not (valid_3) Then Exit Do
>
>
> Loop While (False) '---so that it executes only once.
>
Miha Markic
03-16-2000, 03:34 AM
>
> Haven't you heard Colin? GoTos are the work of Satan.
>
LOL. I vote for break/continue.
Miha
Colin McGuigan
03-16-2000, 11:38 AM
Tom Barnaby wrote in message <38d038dd$1@news.devx.com>...
>
>Haven't you heard Colin? GoTos are the work of Satan.
>
Wasn't aware that I had personally invented those. Ah, time flies. =)
No, but I'm serious; how was the fake do/loop proposed any better than a
GoTo?
--
Colin McGuigan
devx.com
Copyright WebMediaBrands Inc. All Rights Reserved