Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Passing a list to an array

Just curious to know if it is possible to convert a listbox of values
to an array, such as:

Dim arrA as variant
with me.listbox1
arrA = array(.list)
end with

Seems like functionality that would make sense.
It's a pain to do the for i = 0 to .listcount - 1 thing to
create an array.

TIA,
Matt

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Passing a list to an array

Matt,

With a small change...remove "array".

Dim arrA As Variant
arrA = Me.ListBox1.List
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Matt" wrote in message ups.com...
Just curious to know if it is possible to convert a listbox of values
to an array, such as:

Dim arrA as variant
with me.listbox1
arrA = array(.list)
end with

Seems like functionality that would make sense.
It's a pain to do the for i = 0 to .listcount - 1 thing to
create an array.

TIA,
Matt

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Passing a list to an array

Thanks Jim but oddly the code below didn't work in 2002 for
me...probably missed something dumb

Private Sub CommandButton1_Click()
Me.ListBox1.AddItem Me.TextBox1
End Sub

Private Sub CommandButton2_Click()
Dim arrVariant As Variant
arrVariant = Me.ListBox1.List
MsgBox arrVariant(0) ' type 13 err
End Sub

TIA,
Matt

Jim Cone wrote:
Matt,

With a small change...remove "array".

Dim arrA As Variant
arrA = Me.ListBox1.List
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Matt" wrote in message ups.com...
Just curious to know if it is possible to convert a listbox of values
to an array, such as:

Dim arrA as variant
with me.listbox1
arrA = array(.list)
end with

Seems like functionality that would make sense.
It's a pain to do the for i = 0 to .listcount - 1 thing to
create an array.

TIA,
Matt


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Passing a list to an array

That array returned by the .list property (for a single column) is a 2 dimensional array.
So you have to specify the column as well as the row...
Msgbox arrVariant(0, 0)
--
Jim Cone
San Francisco, USA
http://www.officeletter.com/blink/specialsort.html



"Matt"
wrote in message
Thanks Jim but oddly the code below didn't work in 2002 for
me...probably missed something dumb

Private Sub CommandButton1_Click()
Me.ListBox1.AddItem Me.TextBox1
End Sub

Private Sub CommandButton2_Click()
Dim arrVariant As Variant
arrVariant = Me.ListBox1.List
MsgBox arrVariant(0) ' type 13 err
End Sub

TIA,
Matt

Jim Cone wrote:
Matt,

With a small change...remove "array".

Dim arrA As Variant
arrA = Me.ListBox1.List
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Matt" wrote in message ups.com...
Just curious to know if it is possible to convert a listbox of values
to an array, such as:

Dim arrA as variant
with me.listbox1
arrA = array(.list)
end with

Seems like functionality that would make sense.
It's a pain to do the for i = 0 to .listcount - 1 thing to
create an array.

TIA,
Matt


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
Passing a list to an array Matt[_41_] Excel Programming 0 August 21st 06 04:58 PM
Passing Byte array to DLL Tom Excel Programming 2 May 4th 06 04:23 PM
Passing array from 2nd sub back to first sub ExcelMonkey[_190_] Excel Programming 2 March 14th 05 06:09 PM
PASSING an array to a sub in VBA Wombat[_2_] Excel Programming 2 November 30th 03 11:48 AM
Passing array to a function GB[_3_] Excel Programming 3 October 21st 03 09:59 AM


All times are GMT +1. The time now is 06:10 PM.

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

About Us

"It's about Microsoft Excel"