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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic array and MSchart???

Status
Not open for further replies.

Smithsco

Technical User
Mar 30, 2003
89
0
0
AU
I have some data that I would like to graph, the catch is the data will not have the same amount of coloums each time, so is there a way I can dynamically create dim arrdata(5, 1 to 5).

I've tried dim arrdata(i, to 1 to i) which just gives me an error "constant expression required"
 
Look up the ReDim statement in VBHelp


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
redim arrdata (i, 1 to i) does not work either. Is there any way to construct it like execute(dim & "qwert" & i), I found that example in the vbscript section.
 
You can't Dim to a variable! That's what Redim is for!

In Declarations:
Dim myArray() as Integer

Then when you want to change:
Redim myArray(5,6)


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
OK say I want to work out and graph a loan, each repayment is a percentage of income, and the income fluctuates.
The graph would display each payment (pulled from a DB) and each projected payment as a line graph over a time period.

The amount of payments is variable. So even if I use a redim I would have to know an exact value :(

This is only an example.

Is the only other way to do a select case and then redim?
 
You can ReDim to a variable:

As Above:
In Declarations:
Dim myArray() as Integer

Then when you want to change:
Redim myArray(myNum, myOtherNum)





________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
OK forgive me if this sounds a bit stupid.
Since I'm using it to create a MSchart don't I need the format DIM arrdata(4, 1 to 4) NOT DIM arrdata(1,4) ???
 
Depends on what you want to achieve!

< DIM arrdata(4, 1 to 4) > will give you a 2-dimensional array of 5 elements (0-4) as its first dimension and 4 elements (1-4) as its second dimension.

< DIM arrdata(1,4) > will give you a 2-dimensional array of 2 elements (0-1) as its first dimension and 5 elements (0-4) as its second dimension.




________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Question:
I am using this code below. I need to add another array because I exceed the 1000 limit with data I am pulling from my database. Can anyone help me on this?

Setup array formula:
WhilePrintingRecords ;
global numbervar seat_array_position := 0;
global stringvar array out_list := [&quot;&quot;, &quot;&quot;];
redim out_list[1000];

stringvar array times:=split({TK_ODET_2003_SB_ASSOC.E_SBLS},&quot; &quot;);
numbervar loops:=ubound(times);
numbervar i;

global numbervar seat_array_position ;

global stringvar array out_list ;

for i:= 1 to loops do(
seat_array_position := seat_array_position + 1 ;

stringvar chnge:=times ;//3:308:1:18,6
stringvar end:= mid(chnge,instrrev(chnge,&quot;:&quot;)+1);
stringvar back:=right(end,len(end)-instr(end,&quot;,&quot;)) ;
if instr(end,&quot;,&quot;)-1 >= 0 then
stringvar front:=left(end,instr(end,&quot;,&quot;)-1 )
else front := &quot;&quot; ;//drops certain values, need to look at this...
stringvar begin:=left(chnge,instrrev(chnge,&quot;:&quot;));

out_list[seat_array_position]:= begin&back&&quot;-&quot;&front;
);
// following line needed to avoid having formula return an array as an result (not allowed syntax)
&quot;&quot;

I have three other formulas that display my out put:
out put 1 formula:
whileprintingrecords ;
global stringvar array out_list ;
local numbervar seat_counter ;
local numbervar seat_counter_start := 1 ;
local numbervar seat_counter_end := 15 ;
local stringvar array sub_seat_set := [&quot;&quot;,&quot;&quot;] ;
redim sub_seat_set [15] ;

for seat_counter := seat_counter_start to seat_counter_end do
sub_seat_set [seat_counter] := out_list [seat_counter] ;

join ( sub_seat_set , &quot; &quot;)

out put 2 formula:
whileprintingrecords ;
global stringvar array out_list ;
local numbervar seat_counter ;
local numbervar seat_counter_start := 16 ;
local numbervar seat_counter_end := 30 ;
local stringvar array sub_seat_set := [&quot;&quot;,&quot;&quot;] ;
redim sub_seat_set [15] ;

for seat_counter := seat_counter_start to seat_counter_end do
sub_seat_set [seat_counter - 15] := out_list [seat_counter] ;

join ( sub_seat_set , &quot; &quot;)

How can i add to my array and my formulas to include 1000 or 2000 more spaces in my arrays???
 
JJB81
This is the VB5/6 forum!


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top