Visual Basic 6: Public versus Private Function
-
Well I don't know if anyone has seen this horror in Visual Basic 6.0 code. One of my colleague was doing his assignment. Now say there are three functions
Function1
,Function2
,Function3
.Function1
is callingFunction2
. But instead of going toFunction2
it goes toFunction3
:doh: . Now I've seen this my own eyes :confused: . We did try keeping a breakpoint at the call ofFunction2
fromFunction1
. When this breakpoint is hit and I tried debugging it through F8 key. And I could not believe my eyes. It was going intoFunction3
. Well after some trial and errors, I changed the function definition ofFunction3
from Public to Private and guess what??? It worked:laugh:. Now the code works fine. Any idea why this was happening? Has anybody seen this before? -
Well I don't know if anyone has seen this horror in Visual Basic 6.0 code. One of my colleague was doing his assignment. Now say there are three functions
Function1
,Function2
,Function3
.Function1
is callingFunction2
. But instead of going toFunction2
it goes toFunction3
:doh: . Now I've seen this my own eyes :confused: . We did try keeping a breakpoint at the call ofFunction2
fromFunction1
. When this breakpoint is hit and I tried debugging it through F8 key. And I could not believe my eyes. It was going intoFunction3
. Well after some trial and errors, I changed the function definition ofFunction3
from Public to Private and guess what??? It worked:laugh:. Now the code works fine. Any idea why this was happening? Has anybody seen this before?Surprisingly, compilers have bugs too. Have you installed Service Pack 6?
Stability. What an interesting concept. -- Chris Maunder
-
Surprisingly, compilers have bugs too. Have you installed Service Pack 6?
Stability. What an interesting concept. -- Chris Maunder
Yes! I have isntalled SP6...
-
Well I don't know if anyone has seen this horror in Visual Basic 6.0 code. One of my colleague was doing his assignment. Now say there are three functions
Function1
,Function2
,Function3
.Function1
is callingFunction2
. But instead of going toFunction2
it goes toFunction3
:doh: . Now I've seen this my own eyes :confused: . We did try keeping a breakpoint at the call ofFunction2
fromFunction1
. When this breakpoint is hit and I tried debugging it through F8 key. And I could not believe my eyes. It was going intoFunction3
. Well after some trial and errors, I changed the function definition ofFunction3
from Public to Private and guess what??? It worked:laugh:. Now the code works fine. Any idea why this was happening? Has anybody seen this before?I think that the coding horror here is that you are still using VB6.
Deja View - the feeling that you've seen this post before.
-
Well I don't know if anyone has seen this horror in Visual Basic 6.0 code. One of my colleague was doing his assignment. Now say there are three functions
Function1
,Function2
,Function3
.Function1
is callingFunction2
. But instead of going toFunction2
it goes toFunction3
:doh: . Now I've seen this my own eyes :confused: . We did try keeping a breakpoint at the call ofFunction2
fromFunction1
. When this breakpoint is hit and I tried debugging it through F8 key. And I could not believe my eyes. It was going intoFunction3
. Well after some trial and errors, I changed the function definition ofFunction3
from Public to Private and guess what??? It worked:laugh:. Now the code works fine. Any idea why this was happening? Has anybody seen this before?Solution: Don't use VB.
Roger Irrelevant "he's completely hatstand"
-
I think that the coding horror here is that you are still using VB6.
Deja View - the feeling that you've seen this post before.
;P;PIf you read my message carefully it's not me who is using VB. It's my colleague.
-
Solution: Don't use VB.
Roger Irrelevant "he's completely hatstand"
I'm not! I'm using VB.NET and C#
-
;P;PIf you read my message carefully it's not me who is using VB. It's my colleague.
Nilesh Hapse wrote:
If you read my message carefully it's not me who is using VB. It's my colleague.
That's what they all say. "Officer, I wasn't coding in VB6. It was my, errrm, friend."
Deja View - the feeling that you've seen this post before.
-
Well I don't know if anyone has seen this horror in Visual Basic 6.0 code. One of my colleague was doing his assignment. Now say there are three functions
Function1
,Function2
,Function3
.Function1
is callingFunction2
. But instead of going toFunction2
it goes toFunction3
:doh: . Now I've seen this my own eyes :confused: . We did try keeping a breakpoint at the call ofFunction2
fromFunction1
. When this breakpoint is hit and I tried debugging it through F8 key. And I could not believe my eyes. It was going intoFunction3
. Well after some trial and errors, I changed the function definition ofFunction3
from Public to Private and guess what??? It worked:laugh:. Now the code works fine. Any idea why this was happening? Has anybody seen this before?There may be a question of scope - your colleague may have inadvertently named Function2 with a global so that if you had: Function1() Function2() Function3() and did not have debugging libraries installed, the code for Function2 (the wrong Function2 in this case) would execute and the debugger would step into Function3. The sequence would be: begin Function1 execute code (possibly under debugger) end Function1 begin and execute WrongFunction2 (debugger can't enter the code so it executes WrongFunction2) begin Function3 execute code end function
-
Well I don't know if anyone has seen this horror in Visual Basic 6.0 code. One of my colleague was doing his assignment. Now say there are three functions
Function1
,Function2
,Function3
.Function1
is callingFunction2
. But instead of going toFunction2
it goes toFunction3
:doh: . Now I've seen this my own eyes :confused: . We did try keeping a breakpoint at the call ofFunction2
fromFunction1
. When this breakpoint is hit and I tried debugging it through F8 key. And I could not believe my eyes. It was going intoFunction3
. Well after some trial and errors, I changed the function definition ofFunction3
from Public to Private and guess what??? It worked:laugh:. Now the code works fine. Any idea why this was happening? Has anybody seen this before?Can you provide some code that exhibits the behaviour?
-
Well I don't know if anyone has seen this horror in Visual Basic 6.0 code. One of my colleague was doing his assignment. Now say there are three functions
Function1
,Function2
,Function3
.Function1
is callingFunction2
. But instead of going toFunction2
it goes toFunction3
:doh: . Now I've seen this my own eyes :confused: . We did try keeping a breakpoint at the call ofFunction2
fromFunction1
. When this breakpoint is hit and I tried debugging it through F8 key. And I could not believe my eyes. It was going intoFunction3
. Well after some trial and errors, I changed the function definition ofFunction3
from Public to Private and guess what??? It worked:laugh:. Now the code works fine. Any idea why this was happening? Has anybody seen this before?Please post the code so we can explain why it's user error and not a problem with the compiler. I have a feeling there's a true Coding Horror lying in wait for us.
cheers, Chris Maunder
CodeProject.com : C++ MVP
-
Surprisingly, compilers have bugs too. Have you installed Service Pack 6?
Stability. What an interesting concept. -- Chris Maunder
Mike Dimmick wrote:
compilers have bugs too
And to fuel it, it is
Visual Basic 6
. :mad: :)Vasudevan Deepak Kumar Personal Homepage Tech Gossips
-
Nilesh Hapse wrote:
If you read my message carefully it's not me who is using VB. It's my colleague.
That's what they all say. "Officer, I wasn't coding in VB6. It was my, errrm, friend."
Deja View - the feeling that you've seen this post before.
Pete O`Hanlon wrote:
That's what they all say.
PosterDeclaration objPosterDeclaration = (Friend_Told_Me_Or_Friend_Used_It) I_Used_It();
:-DVasudevan Deepak Kumar Personal Homepage Tech Gossips
-
Pete O`Hanlon wrote:
That's what they all say.
PosterDeclaration objPosterDeclaration = (Friend_Told_Me_Or_Friend_Used_It) I_Used_It();
:-DVasudevan Deepak Kumar Personal Homepage Tech Gossips
I'd change the variable name to "lie", but otherwise the code is fine...
-
Well I don't know if anyone has seen this horror in Visual Basic 6.0 code. One of my colleague was doing his assignment. Now say there are three functions
Function1
,Function2
,Function3
.Function1
is callingFunction2
. But instead of going toFunction2
it goes toFunction3
:doh: . Now I've seen this my own eyes :confused: . We did try keeping a breakpoint at the call ofFunction2
fromFunction1
. When this breakpoint is hit and I tried debugging it through F8 key. And I could not believe my eyes. It was going intoFunction3
. Well after some trial and errors, I changed the function definition ofFunction3
from Public to Private and guess what??? It worked:laugh:. Now the code works fine. Any idea why this was happening? Has anybody seen this before?Try
#define public private
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001