|
-
Dec 7th, 2001, 02:30 PM
#1
Thread Starter
Frenzied Member
Coding Question
This is a example I was just given.
Ive seen people do this twice now.
VB Code:
Private Function FileExists(FullFileName As String) As Boolean
On Error GoTo MakeF
'If file does Not exist, there will be an Error
Open FullFileName For Input As #1
Close #1
'no error, file exists
DoExists = True
Exit Function
MakeF:
'error, file does Not exist
DoExists = False
Exit Function
End Function
The last 2 lines dont make sense to me...
Exit function
End Function
Why exit the function when its ending anyway???
-
Dec 7th, 2001, 02:31 PM
#2
Member
It will end itself but it doesn't hurt to throw the Exit Function in there; like in QBasic it was good practice to say END rather than just letting the program execute all lines.
-
Dec 7th, 2001, 02:31 PM
#3
id have to agree...its not needed
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Dec 7th, 2001, 02:32 PM
#4
Frenzied Member
It doesn't matter if you exit or not.
seoptimizer2001
VB 6.0, VC++, VI, ASP, JavaScript, HTML,
Perl, XML, SQL Server 2000
If God had intended us to drink beer, He would have given us stomachs.
Please use the [code] and [vbcode] tags in your posts!
If you don't know how to use them please go HERE!

-
Dec 7th, 2001, 02:34 PM
#5
Thread Starter
Frenzied Member
But then isnt that poor coding.. because your using lines you dont need!
-
Dec 7th, 2001, 02:36 PM
#6
id say yes.... wasted space
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Dec 7th, 2001, 02:36 PM
#7
Member
But that's like saying this is bad:
compared to this:
The performace difference is probably not even an issue. I suppose it's your preference.
-
Dec 7th, 2001, 02:41 PM
#8
Thread Starter
Frenzied Member
Originally posted by filburt1
But that's like saying this is bad:
compared to this:
The performace difference is probably not even an issue. I suppose it's your preference.
I see that. but that is a good coding standard
-
Dec 7th, 2001, 02:45 PM
#9
Thread Starter
Frenzied Member
I see that code as being like this.
VB Code:
Private Function FileExists(FullFileName As String) As Boolean
dim i
On Error GoTo MakeF
'If file does Not exist, there will be an Error
Open FullFileName For Input As #1
Close #1
'no error, file exists
DoExists = True
Exit Function
MakeF:
'error, file does Not exist
DoExists = False
for i = 0 to 5000
exit function
next
End Function
-
Dec 7th, 2001, 02:46 PM
#10
Member
Well that's just silly.
-
Dec 7th, 2001, 02:57 PM
#11
Just to be a chump: Actually your example Filburt isn't the same thing because if you don't dim it as a long then it becomes a variant by default but if you take out the exit then the code is still the same.
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
|