msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Variable as part of a variable name

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax
Author Message
Angus Kelsey



Joined: 04 Oct 2007
Posts: 1

PostPosted: Mon Nov 20, 2006 5:53 am    Post subject: Variable as part of a variable name Reply with quote

How do I insert a string into a variable name?

Let's say I have 10 labels named col1 to col10, and I want to give them all
the same caption - something along the lines of this:

col[1 to 10].text = ""
or

Dim currentLbl
For currentLbl = 1 to 10
col[currentLbl].Text = ""
Next

Both do not work - I have Visual Studio.Net 2003

Any help would be greatly appreciated, as I am relatively new to programming

Archived from group: microsoft>public>vb>syntax
Back to top
View user's profile Send private message
Argusy



Joined: 04 Oct 2007
Posts: 105

PostPosted: Tue Nov 21, 2006 2:48 am    Post subject: Re: Variable as part of a variable name Reply with quote

Angus Kelsey wrote:
> How do I insert a string into a variable name?
>
> Let's say I have 10 labels named col1 to col10, and I want to give them all
> the same caption - something along the lines of this:
>
> col[1 to 10].text = ""
> or
>
> Dim currentLbl
> For currentLbl = 1 to 10
> col[currentLbl].Text = ""
> Next
>
> Both do not work - I have Visual Studio.Net 2003
>
> Any help would be greatly appreciated, as I am relatively new to programming
>

Sorry, this newsgroup is populated with mainly "classic" VB6 or below
scholars.

Try a newsgroup with 'dotnet' in its name.

In classic VB, your for.. next.. would work, So I guess that's another
reason for me to stay away from vb.not

Argusy
Back to top
View user's profile Send private message
Jeff Johnson



Joined: 04 Oct 2007
Posts: 1327

PostPosted: Mon Nov 20, 2006 2:02 pm    Post subject: Re: Variable as part of a variable name Reply with quote

"Argusy" wrote in message @slmember.on.net...

>> col[currentLbl].Text = ""

> In classic VB, your for.. next.. would work, So I guess that's another
> reason for me to stay away from vb.not

Not with those brackets in there....
Back to top
View user's profile Send private message
Argusy



Joined: 04 Oct 2007
Posts: 105

PostPosted: Tue Nov 21, 2006 3:52 pm    Post subject: Re: Variable as part of a variable name Reply with quote

Jeff Johnson wrote:
> "Argusy" wrote in message
> @slmember.on.net...
>
>
>>> col[currentLbl].Text = ""
>>
>
>>In classic VB, your for.. next.. would work, So I guess that's another
>>reason for me to stay away from vb.not
>
>
> Not with those brackets in there....
>
>

You're right, wood and trees bit.

Graham

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Object variable or With block variable not set error that sh I'm trying to encapsulate some common report functionality in my app in a report class module. Below is how I declare and instantiate the class. Note that there is no error when I display the report. Option Explicit Dim arCurrent As clsReport Private Sub

Object variable or with block variable not set I have an object variable defined in the module - something like Dim xxx as Object. In one of the class module say class A, i set the value of xxx, by doing something like Set xxx = objManager. In another class module say Class B, in one of the functions

VB6 - Initializing a variable If I have created a Type, with several fields, is there a way, in VB6 to initialize all members to 0. I am looking for the VB equivalent to the C/C++ of memset(). Many thanks,

pass variable Hi, Can I pass a variable from a form to another? Do I have to define again this var in another page? for example: I define a variable in MDIfrom and assign it a value, I want another form when loaded to get this value of the variable. Thanks for any idea

"Object variable no set" ERROR I have a ListBox in a form. In this form I have connected with a database with a DAO. I try fill the list box with the records from this database. At the Form_Load i write : Dim r As Recordset Set r = r.MoveFirst <----error Do List1
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group