Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default Problem setting text on a userform's "label"

I have a Userform that contains a Label form and here is
the initialize code:
--------------------------------------------
Private Sub UserForm_Initialize()
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Problem setting text on a userform's "label"

Your code worked perfectly for me (xl2003).

Although, I would have used this SetMyLabel procedure instead:

Public Sub SetMyLabel()
Dim s1 As String, s2 As String

s1 = "Hello "
s2 = "World!"
Me.Label1.Caption = s1 & s2 ' This code has no effect
End Sub

I put this code inside the userform module (not in a general module).

The Me keyword refers to the object owning the code--and I don't have to worry
about the name of the userform being renamed.

Maybe, that's the problem. The userform that's being initialized isn't named
Userform1. And you're really changing the label on the wrong userform.

ps.

Dim s1, s2 as string
declares s2 as a string, but s1 is declared as a variant.



Robert Crandal wrote:

I have a Userform that contains a Label form and here is
the initialize code:
--------------------------------------------
Private Sub UserForm_Initialize()
.
.
Call SetMyLabel ' procedure call
End Sub
----------------------------------------------
Public Sub SetMyLabel()
Dim s1, s2 as String

s1 = "Hello "
s2 = "World!"
UserForm1.Label1.Caption = s1 & s2 ' This code has no effect
End Sub
-----------------------------------------------

So, when this code runs, my label ends up being blank.
Is it because the "SetMyLabel" procedure and all its local
variables get deallocated after the procedure runs, so therefore
the text on the label remains blank?? How can i fix this??

thank u


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data label with text "N/A" exalan Charts and Charting in Excel 3 March 22nd 18 09:45 AM
How can I reset the default pie chart label "Other" to "Equity"? russ Charts and Charting in Excel 1 December 3rd 09 08:31 PM
Setting values for "TRUE","FALSE" and "#REF!" Hurtige[_2_] Excel Programming 1 August 11th 06 12:31 PM
"Linkize" a text box or label Rishi Dhupar Excel Programming 5 February 1st 06 05:35 PM
Insert "-" in text "1234567890" to have a output like this"123-456-7890" Alwyn Excel Discussion (Misc queries) 3 October 25th 05 11:36 PM


All times are GMT +1. The time now is 04:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"