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

leo013 wrote:

> does someone know how to convert a string to set a label, the following code
> gives a "Type mismatch"

You have to explain what you mean by "convert" a string, what do you 
want to do?

> Private Sub Command1_Click()
>   Dim str As String
>   txt = Label3

Here you get the caption of label 3 and put it in the variable txt.

>   Set lb = txt

Here you try to set the object variable lb to a text string. That is not 
possible because you can only use the Set statement to make an object 
variable reference an object, and a text string is not an object.

If you skip the Set statement you will set the default property of the 
lb object to the txt string.

>   lb.Caption = "Hi"

This would be ok if lb were a reference to an object with a property 
called Caption, then it would set that property to "Hi".

> End Sub
> 
> and this following works fine:
> 
> Private Sub Command1_Click()
>   Dim str As String
>   Set lb = Label3
>   lb.Caption = "Hi"
> End Sub

Private Sub Command1_Click()
   Dim str As String
   str = "Hi"
   Label3 = str
End Sub

or

Private Sub Command1_Click()
   Dim str As String
   str = "Hi"
   Label3.Caption = str
End Sub

or

Private Sub Command1_Click()
   Dim str As String
   Dim lb As Label
   str = "Hi"
   Set lb = Label3
   lb = str
End Sub

If this does not help you to understand what is happening you will have 
to explain what you want to do.

-- 
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 8:03:41 AM
* 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™.