PRACTICA IV-7.      uso de for next

EQUIPO   No5

 

 

 

OBJETIVO.- Aprender a utilizar el ciclo For Next

 

PROCEDIMIENTO.- Para esta práctica el procedimiento es el siguiente:

 

 

  1. Generar un nuevo Proyecto EXE estandar

 

 

Editar código: Form evento: Activate

 

Option Explicit

 

Private Sub Form_Activate()

Dim intVentas(1 To 6) As Integer

Dim strMensaje As String * 25

Dim intContador As Integer

Dim intSuma As Integer

Dim intMaximo As Integer

 

'  Primer proceso iteractico: preguntar datos.

 

For intContador% = 1 To 6

    strMensaje$ = "Captura el Numero  " & _

        Format(intContador%, "##")

    intVentas%(intContador%) = _

        InputBox("Dame un numero entero", strMensaje$)

Next intContador%

 

'Segundo proceso iteractivo: dsplegar lo capturado.

 

Print "Captura- - -"

For intContador% = 1 To 6

    Print intVentas%(intContador)

Next intContador%

 

'Tercer proceso iterativo: sumar cantidades

'y determinar el numero maximo

 

For intContador% = 1 To 6

    intSuma% = intSuma + CInt(intVentas%(intContador%))

    If intVentas%(intContador%) > intMaximo% Then

        intMaximo% = intVentas%(intContador%)

    End If

Next intContador%

Print ""

Print "Resultados - - -"

 

Print "La Suma es " & Format(intSuma%, "###,###,###.##")

Print ""

Print "El Numero maximo fue " & _

Format(intMaximo%, "###,###,###.##")

 

 

                              

 

 

 

 

                                               

 

 

 

 

 

 

 

CONCLUSIONES: El uso de For Next es muy útil pues nos ahorra código y ademas nos permite entenderlo de una mejor forma.