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

filling fields 1

Status
Not open for further replies.

skate

Technical User
Nov 29, 2002
65
CA
i have an array(9) and want to fill corresponding txtboxes so that array(0) fills txtbox0, array(1) fills txtbox1, array(2) fills txtbox2. is there a way to do this with a loop?
 
How about this code?

Dim intCounter as integer
For intCounter = 0 to 9
txtbox(intCounter).text = array(intCounter + 1).text
Next intCounter HTH,
Randy Smith
California Teachers Association
 
Skate,

First of all, I'm glad to see I'm not the only one that is looking on multiple websites for help :) (saw the same post on dbforums.com). Here's the same answer I posted there:
[tt]
For i = 0 To 9 Step 1
Controls("txt" & i).value = myarray(i)
Next i
[/tt]

I don't think Randy's code will work in VBA. For some reason Micro$oft decided not to allow control arrays in VBA so you cant just name it txtbox(int). Thankfully there is a way around it.. just not as neat looking. -Dustin
Rom 8:28
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top