Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Variant Array Copy, Array row contains Object

Hi All,
For the first time I had a need to put an object inside a two dimension
variant array.

The proc below was for some initial testing.
I had to code an object test at the line marked with 1.

I was surprised that the 'copy' at line 2. worked.
Can you tell me why?

Thanks.
Neal Z.



Sub Test()
Dim vArray, vArrayB
Dim Row As Long, Col As Long

ReDim vArray(1 To 2, 1 To 2)

Set vArray(1, 1) = ActiveWorkbook
vArray(1, 2) = "abc"
vArray(2, 1) = 24
Set vArray(2, 2) = ActiveSheet

ReDim vArrayB(LBound(vArray, 1) To UBound(vArray, 1), _
LBound(vArray, 2) To UBound(vArray, 2))

For Row = LBound(vArray, 1) To UBound(vArray, 1)
For Col = LBound(vArray, 2) To UBound(vArray, 2)

If Not IsObject(vArray(Row, Col)) Then
vArrayB(Row, Col) = vArray(Row, Col)
Else
'1. for individual items, Set is needed, expected.
Set vArrayB(Row, Col) = vArray(Row, Col)
End If
Next Col
Next Row

' 2. Why does this not 'error out' ?
vArrayB = vArray
End Sub
--
Neal Z
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Variant Array Copy, Array row contains Object


Basic knows how to copy an array. Basic is funny that things you
expect to work will not work, and things you don't expect to work will
work. Microsoft version of Basic is poorly documented and Microsoft
implimented legacy features in other versions of Basic without
documenting the features. I believe WANG originally developed Basic in
the 1970's and did a prettty good job of documenting the features of the
language. Microsft doesn't do a good job of documenting the VBA
language so yo uare never sure what will work unless you try or know
from experience.


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=194749

http://www.thecodecage.com/forumz

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Variant Array Copy, Array row contains Object

A shorter example

Sub test2()
Dim a(1), b()
Set a(1) = ThisWorkbook
b = a
Debug.Print b(1).Name
Debug.Print ObjPtr(ThisWorkbook), ObjPtr(a(1)), ObjPtr(b(1))
End Sub

Behind the scenes the object pointer stored in a(1) is copied to b(1)

Regards,
Peter T


"Neal Zimm" wrote in message
...
Hi All,
For the first time I had a need to put an object inside a two dimension
variant array.

The proc below was for some initial testing.
I had to code an object test at the line marked with 1.

I was surprised that the 'copy' at line 2. worked.
Can you tell me why?

Thanks.
Neal Z.



Sub Test()
Dim vArray, vArrayB
Dim Row As Long, Col As Long

ReDim vArray(1 To 2, 1 To 2)

Set vArray(1, 1) = ActiveWorkbook
vArray(1, 2) = "abc"
vArray(2, 1) = 24
Set vArray(2, 2) = ActiveSheet

ReDim vArrayB(LBound(vArray, 1) To UBound(vArray, 1), _
LBound(vArray, 2) To UBound(vArray, 2))

For Row = LBound(vArray, 1) To UBound(vArray, 1)
For Col = LBound(vArray, 2) To UBound(vArray, 2)

If Not IsObject(vArray(Row, Col)) Then
vArrayB(Row, Col) = vArray(Row, Col)
Else
'1. for individual items, Set is needed, expected.
Set vArrayB(Row, Col) = vArray(Row, Col)
End If
Next Col
Next Row

' 2. Why does this not 'error out' ?
vArrayB = vArray
End Sub
--
Neal Z



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Variant Array Copy, Array row contains Object

Thanks Joel,
Sure is nice to know Excel VBA knows how to copy an entire array but
hiccoughs on one item in the array. LOL.

I know I'm dating myself here, but I know from first hand experience,
because I was there, that Basic was invented at Dartmouth College in the
early 1960's.
The head of the Math Department, John Kemeny, and another math professor
John Kurtz, along with some graduate students wrote it. (Interesting to note
that Kemeny later became president of Dartmouth, he was an absolutely
brilliant man.)
They gave it to General Electric, in exchange for which, GE gave
Dartmouth a couple of rooms full of computers. (They were a maker of big
mainframes back in the day...)
I don't know if you're old enough to remember the power plant accident
at Three Mile Island, but it you Google it, you may run into Kemeny's name
again as he headed up the Federal Commission which investigated the accident.

Thanks again,
Neal

--
Neal Z


"joel" wrote:


Basic knows how to copy an array. Basic is funny that things you
expect to work will not work, and things you don't expect to work will
work. Microsoft version of Basic is poorly documented and Microsoft
implimented legacy features in other versions of Basic without
documenting the features. I believe WANG originally developed Basic in
the 1970's and did a prettty good job of documenting the features of the
language. Microsft doesn't do a good job of documenting the VBA
language so yo uare never sure what will work unless you try or know
from experience.


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=194749

http://www.thecodecage.com/forumz

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Variant Array Copy, Array row contains Object

Thanks again Peter,
It's the behind the scenes stuff that drives me a little bit crazy from
time to time.

--
Neal Z


"Peter T" wrote:

A shorter example

Sub test2()
Dim a(1), b()
Set a(1) = ThisWorkbook
b = a
Debug.Print b(1).Name
Debug.Print ObjPtr(ThisWorkbook), ObjPtr(a(1)), ObjPtr(b(1))
End Sub

Behind the scenes the object pointer stored in a(1) is copied to b(1)

Regards,
Peter T


"Neal Zimm" wrote in message
...
Hi All,
For the first time I had a need to put an object inside a two dimension
variant array.

The proc below was for some initial testing.
I had to code an object test at the line marked with 1.

I was surprised that the 'copy' at line 2. worked.
Can you tell me why?

Thanks.
Neal Z.



Sub Test()
Dim vArray, vArrayB
Dim Row As Long, Col As Long

ReDim vArray(1 To 2, 1 To 2)

Set vArray(1, 1) = ActiveWorkbook
vArray(1, 2) = "abc"
vArray(2, 1) = 24
Set vArray(2, 2) = ActiveSheet

ReDim vArrayB(LBound(vArray, 1) To UBound(vArray, 1), _
LBound(vArray, 2) To UBound(vArray, 2))

For Row = LBound(vArray, 1) To UBound(vArray, 1)
For Col = LBound(vArray, 2) To UBound(vArray, 2)

If Not IsObject(vArray(Row, Col)) Then
vArrayB(Row, Col) = vArray(Row, Col)
Else
'1. for individual items, Set is needed, expected.
Set vArrayB(Row, Col) = vArray(Row, Col)
End If
Next Col
Next Row

' 2. Why does this not 'error out' ?
vArrayB = vArray
End Sub
--
Neal Z



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Variant Array Copy, Array row contains Object


I don't remember GE being associatted with Basic. The first Basic I
used was on a WANG computer into 1977 that had the language HARD-WIRED
into the computer. Some how the licensing got from GE to WNAG.
Searching the WEb there is a strong tie between the two companies. He
is a portion of an article from 1984


Article from:PR Newswire Article date:April 10, 1984CopyrightCOPYRIGHT
2009 PR Newswire Association LLC. This material is published under
license from the publisher through the Gale Group, Farmington Hills,
Michigan. All inquiries regarding rights or concerns about this
content should be directed to customer service. (Hide copyright
information) Related articles

NEW YORK, April 10 /PRNewswire/ -- General Electric Information
Services Company today announced availability of a valued-added network
and greatly expanded office communications offerings as part of its
strategy to serve corporations in what will grow to be a $200 billion
computing services and business communications marketplace in the next
five years.

The company also announced a joint agreement with Wang Laboratories,
Inc. that will allow users of the Wang Professional Computer to access
GE Information Services' worldwide teleprocessing network and its office
electronic mailbox service, the QUIK-COMM(TM) System.

"We are announcing a set of integrated capabilities that will enable
corporations to better manage the information explosion taking place in
business today," said Walter W. Williams, chairman of the board and
president, GE Information Services. "The marketplace requires that
corporations get at information when it is needed, where it is needed …


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=194749

http://www.thecodecage.com/forumz

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Cells to variant array Jean-Pierre Bidon Excel Programming 2 April 13th 06 01:00 PM
ReDim Variant array for worksheet copy John Keith[_2_] Excel Programming 1 February 16th 06 09:52 PM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 6 November 9th 05 05:54 AM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 1 November 8th 05 04:21 AM
ReDim Object array as parameter of Variant array Peter T Excel Programming 4 May 10th 05 02:11 PM


All times are GMT +1. The time now is 02:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"