Problem setting text on a userform's "label"

  • Thread starter Thread starter Robert Crandal
  • Start date Start date
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.
 
Back
Top