|     Inicio    |   |         |  |   FOROS      |  |      |      
   Elastix - VoIP B4A (Basic4Android) App inventor 2 PHP - MySQL
  Estación meteorológica B4J (Basic4Java) ADB Shell - Android Arduino
  Raspberry Pi Visual Basic Script (VBS) FireBase (BD autoactualizable) NodeMCU como Arduino
  AutoIt (Programación) Visual Basic Cosas de Windows Webs interesantes
Translate:
Búsqueda en este sitio:


.

Autoit en español
Aplicaciones con Autoit - Juan Antonio Villalpando

-- Tutorial de iniciación a Autoit --

Volver al índice del tutorial

____________________________

27.- Bucle For ... Next. While ... When.

___________________________________________
1.- Bucle For ... Next.

- Va acumulando en la variable $todo cada una de las multiplicaciones. Las va mostrando poco a poco.

Bucle For ... Next
				    
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Tabla de multiplicar - Juan A. Villalpando", 434, 426, 192, 132)
$Label1 = GUICtrlCreateLabel("Escribe un número del 1 al 12", 32, 24, 178, 20)
$Input1 = GUICtrlCreateInput("4", 224, 24, 145, 24)
$Button1 = GUICtrlCreateButton("Pulsa", 128, 72, 153, 49)
$Label2 = GUICtrlCreateLabel("Label2", 48, 168, 333, 332)
GUISetState(@SW_SHOW)
; Juan A. Villalpando - KIO4.COM
#EndRegion ### END Koda GUI section ###

$multiplicando = 0
$multiplicacion = 0
$todo = ""

While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop

    Case $msg = $Button1
        $multiplicando = GUICtrlRead($Input1)
        If $multiplicando > 12 Then
                MsgBox(0, "Error.", "Número demasiado grande.")
        Else
                GUICtrlSetState($Button1, $GUI_HIDE) ; Oculta el botón.
                $todo = ""
                For $n = 1 to 10
                $multiplicacion = $multiplicando * $n
                $todo = $todo & $multiplicando & " x " & $n & " = " & $multiplicacion & @CRLF
                GUICtrlSetData($Label2, $todo)
                Sleep (500) ; Poco a poco.
                Next
                GUICtrlSetState($Button1, $GUI_SHOW) ; Muestra el botón.
                Beep(500, 1000) ; Sonido final.
        EndIf

EndSelect
Wend
Exit

___________________________________________
2.- Bucle While ... Wend.

Bucle While ... Wend
				   
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Tabla de multiplicar - Juan A. Villalpando", 434, 426, 192, 132)
$Label1 = GUICtrlCreateLabel("Escribe un número del 1 al 12", 32, 24, 178, 20)
$Input1 = GUICtrlCreateInput("4", 224, 24, 145, 24)
$Button1 = GUICtrlCreateButton("Pulsa", 128, 72, 153, 49)
$Label2 = GUICtrlCreateLabel("Label2", 48, 168, 333, 332)
GUISetState(@SW_SHOW)
; Juan A. Villalpando - KIO4.COM
#EndRegion ### END Koda GUI section ###

$multiplicando = 0
$multiplicacion = 0
$todo = ""

While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop

    Case $msg = $Button1
        $multiplicando = GUICtrlRead($Input1)
        If $multiplicando > 12 Then
                MsgBox(0, "Error.", "Número demasiado grande.")
        Else
                GUICtrlSetState($Button1, $GUI_HIDE) ; Oculta el botón.
                $todo = ""
                $n = 1
                While $n < 10
                $multiplicacion = $multiplicando * $n
                $todo = $todo & $multiplicando & " x " & $n & " = " & $multiplicacion & @CRLF
                GUICtrlSetData($Label2, $todo)
                Sleep (500) ; Poco a poco.
                $n = $n + 1
                Wend
                GUICtrlSetState($Button1, $GUI_SHOW) ; Muestra el botón.
                Beep(500, 1000) ; Sonido final.
         EndIf

EndSelect
Wend
Exit

___________________________________________
3.- If... Then

If ... Then
 

_________________

- Mi correo:
juana1991@yahoo.com
- KIO4.COM - Política de cookies. Textos e imágenes propiedad del autor:
© Juan A. Villalpando
No se permite la copia de información ni imágenes.
Usamos cookies propias y de terceros que entre otras cosas recogen datos sobre sus hábitos de navegación y realizan análisis de uso de nuestro sitio.
Si continúa navegando consideramos que acepta su uso. Acepto    Más información