Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Defining the length of an array variably

Is it possible to define the length of an array using a varaible. I have
tried:

Public blnCheckBoxArray(intNumberCheckboxes) As Boolean

but I get error message saying that a fixed value is expected. I ought to be
possible. The integer intNumberCheckboxes is set in the beginning of the
program so it does not change when running. Should I write something like
ByVal? I do not know...Please help me on this one if you can!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Defining the length of an array variably

You musr ReDim your array somewhere in your code:

'---------------------------------------------------------------
Public blnCheckBoxArray() As Boolean

Sub tester()
Dim intNumberCheckboxes As Integer

intNumberCheckboxes = 10
ReDim blnCheckBoxArray(intNumberCheckboxes)
End Sub

'---------------------------------------------------------------

HTH
--
AP

"franzklammer" a écrit dans le
message de news: ...
Is it possible to define the length of an array using a varaible. I have
tried:

Public blnCheckBoxArray(intNumberCheckboxes) As Boolean

but I get error message saying that a fixed value is expected. I ought to
be
possible. The integer intNumberCheckboxes is set in the beginning of the
program so it does not change when running. Should I write something like
ByVal? I do not know...Please help me on this one if you can!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Defining the length of an array variably

yes I have tried that. however I get the message: Complie error Matrix
dimension already set. Any clues? Please I just dont get it....

"Ardus Petus" skrev:

You musr ReDim your array somewhere in your code:

'---------------------------------------------------------------
Public blnCheckBoxArray() As Boolean

Sub tester()
Dim intNumberCheckboxes As Integer

intNumberCheckboxes = 10
ReDim blnCheckBoxArray(intNumberCheckboxes)
End Sub

'---------------------------------------------------------------

HTH
--
AP

"franzklammer" a écrit dans le
message de news: ...
Is it possible to define the length of an array using a varaible. I have
tried:

Public blnCheckBoxArray(intNumberCheckboxes) As Boolean

but I get error message saying that a fixed value is expected. I ought to
be
possible. The integer intNumberCheckboxes is set in the beginning of the
program so it does not change when running. Should I write something like
ByVal? I do not know...Please help me on this one if you can!




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Defining the length of an array variably

Hi Franz,

yes I have tried that. however I get the message: Complie error Matrix
dimension already set. Any clues? Please I just dont get it....


Show the problematic code.

The error could be produced with code like:

'===============
Dim intNumberCheckboxes As Long
Dim blnCheckBoxArray(1 To 10)

intNumberCheckboxes = 10

ReDim blnCheckBoxArray(intNumberCheckboxes)
'<<===============

In which case either delete:

Dim blnCheckBoxArray(1 To 10)

or replace it with:

Dim blnCheckBoxArray()


---
Regards,
Norman


"franzklammer" wrote in message
...
yes I have tried that. however I get the message: Complie error Matrix
dimension already set. Any clues? Please I just dont get it....

"Ardus Petus" skrev:

You musr ReDim your array somewhere in your code:

'---------------------------------------------------------------
Public blnCheckBoxArray() As Boolean

Sub tester()
Dim intNumberCheckboxes As Integer

intNumberCheckboxes = 10
ReDim blnCheckBoxArray(intNumberCheckboxes)
End Sub

'---------------------------------------------------------------

HTH
--
AP

"franzklammer" a écrit dans le
message de news: ...
Is it possible to define the length of an array using a varaible. I
have
tried:

Public blnCheckBoxArray(intNumberCheckboxes) As Boolean

but I get error message saying that a fixed value is expected. I ought
to
be
possible. The integer intNumberCheckboxes is set in the beginning of
the
program so it does not change when running. Should I write something
like
ByVal? I do not know...Please help me on this one if you can!






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Defining the length of an array variably

franzklammer wrote:
Is it possible to define the length of an array using a varaible. I have
tried:

Public blnCheckBoxArray(intNumberCheckboxes) As Boolean

but I get error message saying that a fixed value is expected. I ought to be
possible. The integer intNumberCheckboxes is set in the beginning of the
program so it does not change when running. Should I write something like
ByVal? I do not know...Please help me on this one if you can!


Hi franzklammer,

I think you have to leave the brackets empty...

Public blnCheckBoxArray() As Boolean

then after the value of intNumberCheckboxes has been determined you use
the ReDim statement to get the array inplace...

ReDim blnCheckBoxArray(intNumberCheckboxes)

Ken Johnson



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
Defining a variable length area for output. JHB Excel Discussion (Misc queries) 2 August 5th 09 10:43 PM
defining an array for INDEX Dave F[_2_] Excel Discussion (Misc queries) 1 October 2nd 07 07:51 PM
Defining an array to search by Justlearnin Excel Discussion (Misc queries) 4 April 25th 07 04:59 PM
User picks a text file, macro defining the array Tom Ogilvy Excel Programming 1 April 14th 05 07:34 PM
array length in VBA itsmaheshp[_4_] Excel Programming 1 November 9th 04 01:08 PM


All times are GMT +1. The time now is 06:00 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"