Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Label Caption Property (2000)

    I am trying to simulate rolling a die using a form and labels. Depending on the value of a randomly generated number, the caption properties of 7 labels are set. Here is part of the code I am using which, overall, is not working properly.

    Private Sub CommandButton1_Click()
    Randomize
    x = Int(Rnd() * 6) + 1
    Select Case x = 1
    Case x = 1
    UserForm1.Label1.Caption = ""
    UserForm1.Label2.Caption = ""
    UserForm1.Label3.Caption = ""
    UserForm1.Label4.Caption = ""
    UserForm1.Label5.Caption = ""
    UserForm1.Label6.Caption = ""
    UserForm1.Label7.Caption = "l"
    Case x = 2
    UserForm1.Label1.Caption = ""
    UserForm1.Label2.Caption = ""
    UserForm1.Label3.Caption = "l"
    UserForm1.Label4.Caption = "l"
    UserForm1.Label5.Caption = ""
    UserForm1.Label6.Caption = ""
    UserForm1.Label7.Caption = ""
    Case x = 3
    UserForm1.Label1.Caption = ""
    UserForm1.Label2.Caption = ""
    UserForm1.Label3.Caption = "l"
    UserForm1.Label4.Caption = "l"
    UserForm1.Label5.Caption = ""
    UserForm1.Label6.Caption = ""
    UserForm1.Label7.Caption = "l"
    End Select

    Can anyone see the problem or offer a better solution?

    TIA
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Label Caption Property (2000)

    You should change

    Select Case x = 1

    to

    Select Case x

    and

    Case x = 1

    to

    Case 1

    etcetera.

  3. #3
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Label Caption Property (2000)

    It works a treat. Thanks, Hans.
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •