Public Sub Form_Open()
Dim i As Integer
Me.Show
Wait 0.5
lbl01.Visible = False
lbl01.Text = "1"
lbl02.Visible = False
lbl02.Text = "2"
lbl03.Visible = False
lbl03.Text = "3"
lbl04.Visible = False
lbl04.Text = "4"
lbl05.Visible = False
lbl05.Text = "5"
lbl06.Visible = False
lbl06.Text = "6"
lbl07.Visible = False
lbl07.Text = "7"
lbl08.Visible = False
lbl08.Text = "8"
lbl09.Visible = False
lbl09.Text = "9"
lbl10.Visible = False
lbl10.Text = "10"
Do
i = Rand(1, 10)
Me.Children[i - 1].Visible = True
Wait 1
Me.Children[i - 1].Visible = False
Loop
End
(15-08-2020, 18:18)vuott escribió: ...quizás este simple ejemplo podría ayudar:
Este simple ejemplo supone que las "Label" se coloquen en la Form una tras otra sin solución de continuidad, siguiendo el orden de numeración presente en su propio nombre.Código:Public Sub Form_Open()
Dim i As Integer
Me.Show
Wait 0.5
lbl01.Visible = False
lbl01.Text = "1"
lbl02.Visible = False
lbl02.Text = "2"
lbl03.Visible = False
lbl03.Text = "3"
lbl04.Visible = False
lbl04.Text = "4"
lbl05.Visible = False
lbl05.Text = "5"
lbl06.Visible = False
lbl06.Text = "6"
lbl07.Visible = False
lbl07.Text = "7"
lbl08.Visible = False
lbl08.Text = "8"
lbl09.Visible = False
lbl09.Text = "9"
lbl10.Visible = False
lbl10.Text = "10"
Do
i = Rand(1, 10)
Me.Children[i - 1].Visible = True
Wait 1
Me.Children[i - 1].Visible = False
Loop
End
' Gambas class file
Public Sub Button1_Click()
Dim i As Integer
Dim c As Object
i = Rand(1, 5)
For Each c In Me.Children
If Object.Type(c) = "Label" Then
If c.Name = "lbl" & Format(i, "00") Then
c.visible = True
c.Text = Format(i, "00")
Button1.Text = Format(i, "00")
Else
c.visible = False
Endif
Endif
Next
End
(15-08-2020, 18:46)calcena escribió: Digamos que el Rand lo realizo antes, obtengo el número 01La única manera de obtener el valor, devuelto por la función Rand(), precedido de un cero, es transformarlo en formato de cadena de dos caracteres.