Urgent VB extrae aleatoriamente códigos digitales
Agrega dos Command1 y Command2, un cuadro de texto Text1 y un control de tiempo Timer1 al formulario. El código es el siguiente: Private Sub Command1_Click() 'Inicia la lotería
If Command1. .Caption = "Iniciar" Luego 'Juzga si el botón está en inicio
Command1.Caption = "Detener" 'Sí, cambia el botón para detener
Timer1.Enabled = True 'Girar en el reloj
Else
If Command1.Caption = "Stop" Then 'De lo contrario, determine si el botón está detenido
Timer1.Enabled = False 'Sí, detener el control de tiempo
Command1.Caption = "Inicio" 'Cambiar Comando1 a Inicio
Finalizar si
Finalizar si
Finalizar SubPrivate Sub Command2_Click() 'Borrar el contenido del cuadro de texto
Text1.Text = ""
End SubPrivate Sub Form_Load() 'El evento de carga del formulario inicializa algunos controles
Text1.Text = " " 'Borrar el contenido del cuadro de texto
Timer1.Interval = 10 'Establecer el período de control de tiempo en 10 ms
Timer1.Enabled = False 'El tiempo el control no está habilitado de forma predeterminada
Command1.Caption = "Inicio" 'El nombre predeterminado de Comando1 es Inicio
Command2.Caption = "Borrar" 'El nombre predeterminado de Comando1 es Borrar End Sub Private Sub Timer1_Timer() 'El evento de control de tiempo realiza una extracción aleatoria continua Data
Text1.Text = Int((42 - 1 + 1) * Rnd + 1) 'Método de lectura de números aleatorios: Int( (límite superior (límite superior) - límite inferior (límite inferior) + 1) * Rnd + límite inferior)
End Sub