Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why did Vis Basic do this dumb thing?!!!

Status
Not open for further replies.

crystals

Programmer
Nov 30, 2000
7
0
0
US
I have an array of lines Line1(). Then i load a second array Line2(). Then i say for each member (1-300)

Line2(i) = Line1(i)

Later, when i try to reference BackColor of Line2(i), it comes out as white. I assume when i say Line2(i) = Line1(i), that i mean "Assign all properties of Line1(i) to Line2(i)". Why wouldn't the program assume that i mean that. I had to go back and change my loop to this

Line2(i) = Line1(i)
Line2(i).backcolor = Line1(i).backcolor

for the thing to work

i wouldn't complain, but this took a while to figure out! Darn. Anybody know why this happens this way???

Crystals
 
If i understand it correctly, the code you supplied:
line(2) = line(1)
will only set the default property of the line, which I think is the Visible property. Thus your line of code is equivelant to:
line(2).visible = line(1).visible

You will need to set each property individually
 
Crystals,

Not really an answer to your question, but I couldn't resist.

Visual Basic is just another program.

Like any computer program, it (attempts) to do EXACTLY what you tell it (to do).

The only real question here (and in most programming problems | Bugs) is what EXACTLY did you tell it (the computer program / VB) to Do!

Again, Sorry, Just couldn't resist. Hope you can at least laugh at me.



MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
In an OOP approach; usually one would create a class which has the functionality to directly assign one object to another (copy all properties/attributes to the other object). Due to the fact that certain properties can be private the following is not always possible but... a good idea/challenge would be to write a function which copies all of the attributes from one object to another - but make the object in question totally generic (function works on any object). Rob Marriott
robert_a_marriott@yahoo.com

Hire me! Full-time, contract, whatever...shhh don't let my current employer know I said that.
 
Rob,

Darn it. Your'e trying to get this thread back on a 'serious' track.

What you propose isn't really all that difficult. With just a single caveat/restriction, it should almost be trivial. The restriction would simply be the "objects" are of the same type.

Then, send the routine the two objects, and
For each [Prpty] in obj1.Properties
[tab]Obj2.Prpty = Obj1.Prpty
Next Prpty

Of course it is WAY incomplete, but the concept is pretty simplistic.



MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Yeah, that's what I was looking for - I wasn't 100% sure if there was a &quot;Properties&quot; collection <duh - I should know that> so I added the &quot;challenge&quot; clause just in case.
Cheers, Rob Marriott
robert_a_marriott@yahoo.com

Hire me! Full-time, contract, whatever...shhh don't let my current employer know I said that.
 
Rob,

Are you saying you're actually going to do this?

You better be careful that you don't go to far, or the Ms. Police will get a warrant for your arrest.

Also, you will be ruining my retirement. I have serious plane to 'retire' and only do Microsoft programming. Fixing the systems to work sensibly could put a serious dent in my income potential!

I had hoped to not draw on my 401K's until I was no longer able to use the keyboard or see the monitor (whichever comes first), just based on the arcane things that don't work like they should. Now, you are saying you're going to fix the very things whic h I need to remain broken to make a living?



MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Hi,
No, I'm not going to write that function - I have more important things to do (like re-assembling lost file fragments) than incorporate basic functionality into classes that should have had it to begin with. =) Rob Marriott
robert_a_marriott@yahoo.com

Hire me! Full-time, contract, whatever...shhh don't let my current employer know I said that.
 
Thank you, thank you, thank you, thank you, thank you, [tab][tab][tab]thank you, thank you, thank you, thank you, thank [tab][tab][tab]you, thank you, thank you, thank you, thank [tab][tab][tab][tab]you, thank you, thank you, thank you, [tab][tab][tab][tab][tab]thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you!

p.s. Good luck in sorting the file fragments, and please be kind to the @!$@#$#@$#$$%#$&amp;$#&amp;$#^$#@ who failed to back up and de-frag the system properly. They are potential customers.



MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
crystals,

Just to be sure, how and where (exactly) are the arrays of lines declared?

Could you post the routine where this 'action' takes place?



MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Thanks for all the responses (especially the funny ones). It WAS trivial to write code to fix this, BUT i was just wondering why the language worked this way and i certainly got my answer. All is well and my lines are living fine lives now!

btw, lines were simply declared using for loop with
'Load Line1(i)' statement inside.

Cheers,

C
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top