|
-
February 9th, 2011, 05:48 PM
#1
[RESOLVED] Visual Basic ate my variable!
Can VB6 reassign a value just because it's of the same type? I used a member of a structure in a parameter that will return a structure of the same type as the one used in the parameter. Wait there's more: I used that return in the parameter in another method call (nested methods). My original structure used in the innermost nested method ends up equaling the returned value. To clarify I'm using an integer value of a member of the original structure and is passed by value not reference... Does vb6 not do nested methods?
So below is a simplified illustrated example of how everything is set up:
Code:
'--- Returns a SomeStruct
FunctionC(byVal i as integer) as SomeStruct
.
.
.
end Function
FunctionA()
dim A as SomeStruct
.
.
FunctionB( FunctionC(A.SomeInt) )
.
.
end Function
FunctionB( ByVal B as SomeStruct )
.
.
.
end Function
Somehow during the call to FunctionB, "A" equals what is supposed to be "B" even after FunctionB returns.
Sooo yeah... any ideas?
-
February 9th, 2011, 06:15 PM
#2
Re: Visual Basic ate my variable!
Doesn't make sense. Include a sample.
-
February 9th, 2011, 06:30 PM
#3
Re: Visual Basic ate my variable!
Can't. Proprietary code. Plus it takes awhile to set up you're enviroment (dll's, third-party) so even if I send you the code you can't run it. I'm not allowed to publish even a small portion.
I know it doesn't make sense. I've had my coworkers look at this and we've come to no conclusion. Googling vb6 and nested methods produced nothing.
I'm more wondering if anyone else has had this happen to them.
-
February 9th, 2011, 09:20 PM
#4
Re: Visual Basic ate my variable!
You have not given enough to go on, no idea what B is returning nor what it is being assigned to.
But to answer the part of the question that can be answered, Yes Vb does do nested methods just fine. I have used them numerous times over the years and whenever there was an issue it was always due to a mistake in the code.
Always use [code][/code] tags when posting code.
-
February 10th, 2011, 11:44 AM
#5
Re: Visual Basic ate my variable!
Ok... so it's not vb6 it's a really badly planned/executed DLL class that uses a static global class that has only one instance of the parent member. Using an accessor to retrieve a structure that is a member of the parent class then changes the parent class to point at the structure's parent. Basically if I'm currently pointing to A but I use an accessor to grab a member of B turns A into B.
I know vb6 does nested queries I was wondering if there was an unpublished limitation to its processing/interpretation/execution of nested methods. In this case yes it was the code but I have seen vb6-ism/quirks to defy basic logic (no pun intended). I was hoping this was vb6 because I could use that as another point to let us update this project. If it's our code they'll just say fix it...
Thanks for you for your time everyone...
-
February 10th, 2011, 01:29 PM
#6
Re: Visual Basic ate my variable!
Code:
changes the parent class to point
That would be a pointer, which VB6 does NOT have
-
February 10th, 2011, 02:08 PM
#7
Re: Visual Basic ate my variable!
 Originally Posted by dglienna
That would be a pointer, which VB6 does NOT have
A pointer is not exactly what I'm talking about. I used "point" to mean "reference", or "equals". I can only instantiate one instance of the DLL class. Whenever I query for another structure when I already have one changes all variables of the DLL class to the one I just queried for. Basically I'm only allowed to have/use the one I queried for.
It's not a pointer issue (meaning I tried to use pointers in VB6). This is just a badly designed global class that exists for the life of the application. The parent structure exists independent of any new'ed variable of the class's type or it's children class. The parent controls the children. If I query for another saved structure or one of it's many members (meaning I use an accessor to retrieve a member of a different structure), every variable of that DLL class (parent or child) in existence is then changed and they all "point" to the parent that I queried for.
-
February 10th, 2011, 05:13 PM
#8
Re: Visual Basic ate my variable!
Sounds to me like the problem is in the coding of the DLL. I'd look there. Perhaps something is being passed ByRef when it should be passed ByVal. I exsperanced a similar problem a long time ago when I used VB6 for me it turned out to be a conflect in varibale names. I had a local and a global variable with the same name. I'd attempt to make a change to a local variable and it would change the global instead.
-
February 11th, 2011, 02:20 PM
#9
Re: Visual Basic ate my variable!
Well sort of... apparently the class is set up to only allow one instance of nay object of that class to exist at any one time during the life of the application. Basically when querying for a member the parent queries for EVERYTHING. So the accessor actually refreshes the entire object and every instance of that same class... it's terrible... It's a custom DLL we made (actually someone who doesn't and hasn't for quite awhile works here anymore) is doing this...
-
February 11th, 2011, 03:44 PM
#10
Re: Visual Basic ate my variable!
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
|