Real Software Forums

redim seems not to be working - confused!
Page 1 of 1

Author:  aulay [ Wed May 08, 2013 5:18 pm ]
Post subject:  redim seems not to be working - confused!

I have a very simple bit of code which isn't doing what it should and I'm most perplexed.

The code below has all be cut and pasted directly from a subroutine. It should dim a set of arrays (four string, one integer) and then redim them to fix their required sizes. All very simple.

dim control_temp(-1),control_temp2(-1), control_temp3(-1),control_temp4(-1)   As String
dim deleteme(-1) as integer

redim control_temp(max_years)
redim control_temp2(max_years)
redim control_temp4(max_thresholds-1)
redim deleteme(max_years)

However, when I debug the programme, it seems that whilst the integer array is sized appropriately, the string arrays are not. Instead
I get a report which says (when max_years=70 and (max_thresholds-1)=40)

control_temp String(60)
control_temp2 String(60)
control_temp3 String(40)
control_temp4 String(40)
deleteme Int32(70)

This all makes no sense to me. It's getting late and I'll look again tomorrow, but any ideas very welcome

Author:  npalardy [ Wed May 08, 2013 6:58 pm ]
Post subject:  Re: redim seems not to be working - confused!

trying 2011r4.3 here and I cant get it to do what you're saying

I'd put a break point on the first DIM in your code and check the values are what you expect & then single step

Author:  aulay [ Thu May 09, 2013 2:21 am ]
Post subject:  Re: redim seems not to be working - confused!

Thanks for that. Next line was
control_temp= Split(s, chr(9))

(and more similar) and I'd forgotten that Split redim-ed the array, negating the initial setting. Duh.
Your prompt appreciated.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group