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

Need help with making a label using variables 1

Status
Not open for further replies.

JunoKaguya

Technical User
May 29, 2000
1
0
0
US
How would I be able to make a labels' caption read what is selected in a list?  for example, "The" list1 " is red."  every way I try I get 'expected end of statement'
 
In the list1 click event place code ie:<br><br>label1.caption = list1.text<br><br><br>hope this helps<br><br>bob<br> <p>Robert L Norton<br><a href=mailto:2dogs@webace.com.au>2dogs@webace.com.au</a><br><a href= > </a><br>
 
or even better...
label1.caption = &quot;The&quot; & list1.text & &quot;is red.&quot;
 
By List1, I presume you mean a ListBox control. Try:

DIM ItemFromLstBox As String
ItemFromLstBox = List1.Index(List1.ListIndex)
Label1.Caption = &quot;The &quot; & ItemFromLstBox & &quot;is red&quot;

-MiggyD &quot;The world shrinks more and more with every new user online.&quot;
 
MiggyD's right, but you can shorten it down to a single line if it helps.

Label1.Caption = &quot;The &quot; & List1.Index(List1.ListIndex)& &quot;is red.&quot;
 
I prefer the text property if i'm just reading from the list cuz it's shorter but it doesn't really matter.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top