Improving my code : control array in vbscript

J

JayEff Land

Hi,
I would like to create a array of controls in vbscript on a custom
form in Outlook Xp. I would like to do
transfer the original code format to the improved code format.

original---------------------------------------------------------------

Set oTxtQty1 = FormPage.Controls("txtQty1")
Set oTxtQty2 = FormPage.Controls("txtQty2")
Set oTxtQty3 = FormPage.Controls("txtQty3")
Set oTxtQty4 = FormPage.Controls("txtQty4")
Set oTxtQty5 = FormPage.Controls("txtQty5")
..
..
..
Set oTxtQty(nTimes) = FormPage.Controls("txtQty(nTimes)")


Improved----------------------------------------------------------------

dim oTxtQty(10)
for i=0 to 10
strTxt=cstr("txtQty" & (i + 1))
set oTxtQty(i)=FormPage.controls(strTxt)
next


The second format does not work. It is giving me the error : "Object
variable not set". I supposed it is because my array is not considered
as an object. I have tried to set my object by doing this : set
eval(strTxt(i))=FormPage.controls(strTxt). It does not works either.
Does Anybody knows how I could fixed this and/or improved my coding
format?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top