TIP: Click on subject to list as thread! ANSI
echo: visual_basic
to: All
from: Olof Lagerkvist
date: 2004-06-20 17:08:00
subject: Re: convert a string to s

leo013 wrote:

> i found it !!
> 
> Private Sub Command1_Click()
>   Dim txt As String
>   txt = Label3
>   Me(txt).Caption = "Hi"
> End Sub

Yes. and expressed like you tried before, if you want to have a 
reference variable to your label (e.g. makes it possible to use default 
properties in a simpler way):

   Dim lb As Label
   Dim txt As String
   txt = "Label3"
   Set lb = Controls(txt)
   lb = "Hi"

(In this example, Controls(txt) is equivalent to Me(txt), it is just 
that I find it more "explaining" to write Controls(txt) instead to 
reference a control by name. Me(txt) is an abbreviation for 
Me.Controls(txt).)

Anyway, I strongly recommend you to use control index numbers instead if 
you need to reference different controls with the same code. Then you 
could name all labels just "Label" and give them index numbers and 
reference them in code by writing:

Dim no As Integer
no = 3
Label(no) = "Hi"

....if you want to set the caption of your third label.

-- 
Olof Lagerkvist
ICQ: 724451
Web page: http://here.is/olof
---
þ RIMEGate(tm)/RGXPost V1.14 at BBSWORLD * Info{at}bbsworld.com

---
 * RIMEGate(tm)V10.2áÿ* RelayNet(tm) NNTP Gateway * MoonDog BBS
 * RgateImp.MoonDog.BBS at 6/20/04 5:08:40 PM
* Origin: MoonDog BBS, Brooklyn,NY, 718 692-2498, 1:278/230 (1:278/230)
SEEN-BY: 633/267 270
@PATH: 278/230 10/345 106/1 2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.