Showing results for 
Search instead for 
Do you mean 

VBScript problems...

New Member
Posts: 2
Country: USA

VBScript problems...

I am fairly new to ACT! and it's been a long while since I did much scripting, so my apologies if this is a simple programmer's error.

I'm trying to generate a string array to be used to fill in address lines on a report. I'm hoping to prevent gaps when information is missing. Here's what I'm having a hard time with:

'Create a string array to hold address info
dim address(3)

'Write info to array
address(0) = "Address Line 1"
address(1) = "Address Line 2"
address(2) = "City, State Zip"
address(3) = "Customer Phone"

'Write info into custom fields
custom1.text = address(0)
custom2.text = address(1)
custom3.text = address(2)
custom4.text = address(3)

I'm actually planning on using a loop to populate the custom fields based on what information is available, but that doesn't really matter right now.

The problem I am having is that ACT! is using whatever value was defined last as the value for every container in the array. So in this example we would see this:

Customer Phone
Customer Phone
Customer Phone
Customer Phone

Any help?
Copper Elite Contributor
Posts: 95
Country: USA

Re: VBScript problems...

I'm not that good with VBScript, but shouldn't it be dim address(4)?
Nick Bohne
Effective Solutions, Inc.
Bronze Elite Contributor
Posts: 2,119
Country: United_Kingdom

Re: VBScript problems...

Hi Dagan,
I've forgotten quite a bit of VB since I switche over to C#. Just to confirm, are you using the script within the reports? From the syntax it looks like you are trying to write a custom scrpit so that you do not have blank rows within a report. If this is the case I have battled with this myself and finally gave up!
I agree with Nikolas re the array I think it should be address(4) but the thing that I don't understand is why you do not get a OutOfRangeIndex Error when you try and reference address(3) when it only has 3 indexs? But maybe in VBS arrays are dynamic like vectors?
For the fields such as address line 1, can you use the Object name as oppose to the display name and then explicitly call the field.text property since that might get you the value?
Vivek Gargav
Caldere Associates Ltd.
My Blog
Tuned Listener
Posts: 23
Country: UK

Re: VBScript problems...

vbscript declares arrays using the max index rather than the array length so address(3) should be fine

New Member
Posts: 2
Country: USA

Re: VBScript problems...

I've done a little more research and everything confirms that "dim address(3)" is the propper syntax. Still, no one has any solutions?