Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Data label with text "N/A" | Charts and Charting in Excel | |||
How can I reset the default pie chart label "Other" to "Equity"? | Charts and Charting in Excel | |||
Setting values for "TRUE","FALSE" and "#REF!" | Excel Programming | |||
"Linkize" a text box or label | Excel Programming | |||
Insert "-" in text "1234567890" to have a output like this"123-456-7890" | Excel Discussion (Misc queries) |