Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 2nd, 2006, 08:16 AM
Registered User
 
Join Date: Jan 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default textbox names wth numbers

hello.

i have 9 text boxes.

named txtbox00 , txtbox01 , txtbox02. etc
they continue up until txtbox22.
they are a grid layout.

and i want to loop through them using for loops,
getting them to store what is in an array,
but this does not work.

this is what i am tying to do in the code

For x = 0 To 2
For y = 0 To 2

txtboxxy = grid(x, y)

Next
Next

i have tried some different things all do not work.
like using brackets and apostrophes.

any help thanks.
 
Old January 3rd, 2006, 06:50 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the best way to do this is to change your 2x2 text boxes into an array.
Name the first text box like you want (txtbox is ok, but it does not say what is used for, be more verbose) and set its Index property to 0. Rename the second with the same name, and VB will automatically set the Index property to 1, and continue for all text boxes.
Now the loop will be:

set txtboxxy = txtbox(x + y* numberOfColumns)


As an alternative, you can use the Controls property to get a control by name:

set txtboxxy = me.controls("txtbox" & format(x,"00") & format(y,"00")

My preferred way will be to use a MSFlexGrid instead of a bunch of textBoxes (this is what a grid is for: to display values in a... grid)

PS: all the code is not tested
PPS: remember to use the "set" keyword to assign an object to a variable

Marco





Similar Threads
Thread Thread Starter Forum Replies Last Post
can anybody share ur knowledge wth ajax kunchala_rakesh Ajax 1 September 13th, 2007 10:10 PM
Crystal Reports wth Java anandh J2EE 0 February 28th, 2007 09:13 AM
Need help with matching multiple "begins-wth" dcheslow XSLT 3 January 18th, 2007 04:32 AM
bind a image filename stored in DB wth FORMSVIEW alexdcosta ASP.NET 2.0 Basics 0 June 22nd, 2006 05:30 AM
How Do I Sum Numbers In a TextBox wb8bgy Visual Basic 2005 Basics 1 December 10th, 2005 01:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.