-
Nov 23rd, 2007, 04:59 PM
#1
Thread Starter
Member
-=[Resolved]=- vb6: Exit If statement?
Name says it all.
Is there an Exit If type statment? Like break out of the current If statement without using exit sub?
Thanks in advance, oz.
Last edited by OzMa77; Nov 25th, 2007 at 09:47 AM.
-
Nov 23rd, 2007, 05:04 PM
#2
Re: vb6: Exit If statement?
No, there isn't. Code is executed if falls under your condition anyway or you may need to have multiple IFs... There is also Select Case but it's basically the same thing - just syntax is different.
-
Nov 23rd, 2007, 05:11 PM
#3
Thread Starter
Member
Re: vb6: Exit If statement?
Alright, thanks for the quick reply by the way =)
-
Nov 23rd, 2007, 08:55 PM
#4
Hyperactive Member
Re: vb6: Exit If statement?
Try to use goto
vb Code:
Dim i as integer
i = InputBox("Key In a Value")
if i < 5 Then
Goto GoHere
else
Goto GoThere
End if
gohere:
Msgbox "Here"
goThere:
Msgbox "There"
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
Nov 23rd, 2007, 09:06 PM
#5
Re: vb6: Exit If statement?
I purposely avoided mentioning the GoTo but ...
It has been discussed million and one times so here we go again - other than error handling the goto should not be used.
For more detailed information search forum - there are plenty of discussions on this topic.
-
Nov 24th, 2007, 05:45 AM
#6
Thread Starter
Member
Re: vb6: Exit If statement?
Yeah I thought of GoTo also..it should be used for error handling and such like he said, nothin else.
-
Nov 24th, 2007, 09:39 PM
#7
Re: vb6: Exit If statement?
The only thing you need to "break out of" is a loop. An If statement either executes or it doesn't.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Nov 25th, 2007, 04:03 AM
#8
Re: vb6: Exit If statement?
GoTo should only be used for On Error statements.
To break out of a loop:
Exit Do
Exit While
Exit For
Any other evaluations like an If or Select code blocks dont need an "exit".
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Nov 25th, 2007, 09:47 AM
#9
Thread Starter
Member
Re: vb6: Exit If statement?
Alright, I suppose I can mark this resolved now.
Thanks for the help.
-
Nov 26th, 2007, 01:59 AM
#10
Hyperactive Member
Re: vb6: Exit If statement?
Thanks for advice, i try search from forums why not recommend to use goto unless error handle.
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
Nov 26th, 2007, 02:23 AM
#11
Re: -=[Resolved]=- vb6: Exit If statement?
Because it create an ill effect called "speggetti code" where you end up jumping all over the code processing all the gotos etc. Its bad design logic and most difficult to track when debugging. I remember something about resource usage too but its been a long time since I seen a GoTo being used. Using GoTos is reminescent or the early 1980s BASIC coding
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Nov 26th, 2007, 02:30 AM
#12
Hyperactive Member
Re: -=[Resolved]=- vb6: Exit If statement?
Thanks Roddog your explaination is good :-)
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|