ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using a DO loop to add values into a textbox (https://www.excelbanter.com/excel-programming/339823-using-do-loop-add-values-into-textbox.html)

Ian B

Using a DO loop to add values into a textbox
 
I have a series of textboxes in a form and want to enter the values from an
array into each of the textboxes.

Is there any way to do this using a DO loop rather than having to write out
each textbox one by one

something like

co1 = 0
Do
co1 = co1 + 1
userform1.textbox(co1) = varray(co1)
if co1 = 100 then exit do
Loop

rather than

userform1.textbox1 = varray(1)
userform2.textbox2 = varray(2)
etc
etc

Ian B


Ian B

Using a DO loop to add values into a textbox
 
Hi

Thanks a lot that works great

Ian

"anonymousA" wrote:

Hi

if Ubound(varray)=99 and the Array Base is 0 ,something like that could
make it

With userform1
for I=Lbound(varray) to Ubound(varray)
.controls("TextBox " & I+1) = varray(I)
next
end with

Regards

Ian B a écrit :
I have a series of textboxes in a form and want to enter the values from an
array into each of the textboxes.

Is there any way to do this using a DO loop rather than having to write out
each textbox one by one

something like

co1 = 0
Do
co1 = co1 + 1
userform1.textbox(co1) = varray(co1)
if co1 = 100 then exit do
Loop

rather than

userform1.textbox1 = varray(1)
userform2.textbox2 = varray(2)
etc
etc

Ian B



Dave Peterson

Using a DO loop to add values into a textbox
 
If you name them nicely, maybe...

col = 0
Do
co1 = co1 + 1
userform1.controls("textbox" & co1) = varray(co1)
if co1 = 100 then exit do
Loop

You really have 100 textboxes on your form?


Ian B wrote:

I have a series of textboxes in a form and want to enter the values from an
array into each of the textboxes.

Is there any way to do this using a DO loop rather than having to write out
each textbox one by one

something like

co1 = 0
Do
co1 = co1 + 1
userform1.textbox(co1) = varray(co1)
if co1 = 100 then exit do
Loop

rather than

userform1.textbox1 = varray(1)
userform2.textbox2 = varray(2)
etc
etc

Ian B


--

Dave Peterson


All times are GMT +1. The time now is 05:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com