comandos programacion

Páginas: 3 (677 palabras) Publicado: 25 de noviembre de 2014

Uso de Variables por Referencia (La variable conserva su valor.)

' Imprime la suma y Multi de 2 numeros
' Los parámetros de las sub son Por Referencia( Conserva su valor actualizado)
ModuleModule1
Sub Main()
Dim a As Integer : Dim b As Integer
entrada(a, b)
proceso(a, b)
salida(a, b)
Console.ReadLine()
End Sub

Subentrada(ByRef a, ByRef b) 'Permite que la variable conserve su valor
Console.WriteLine("teclee un num ")
a = Console.ReadLine()
Console.WriteLine()
Console.WriteLine("tecleeotro num ")
b = Console.ReadLine
End Sub

Sub proceso(ByRef a, ByRef b)
Dim r1 As Integer : Dim r2 As Integer
r1 = a + b
r2 = a * b
a = r1b = r2
End Sub

Sub salida(ByRef a, ByRef b)
Console.WriteLine("Suma {0} Mult {1}", a, b)
End Sub
End Module








ARREGLOS
Son variables (con el mismonombre).- que permiten almacenar un conjunto de datos del mismo tipo a la vez.

Dim a(3) As String ‘ Crea 4 variables con índice
a(0)
a(1)
a(2)
a(3)

' Option Strict Off vb puede aceptarcódigo incorrecto
Module Module1

Sub Main()
Dim i As Integer
Dim array(4) As Integer ' define 5 variables del (0,1..4)
array(0) = 3
array(1) = 2array(2) = 1
array(3) = 5
array(4) = 6

For i = 0 To array. Length – 1 ' array.length.-proporciona la Long del arreglo
Console.WriteLine(array(i))Next
Console.ReadLine()
End Sub
End Module


Rem Estudiar Programa
Module Module1
  Sub Main()
      Dim array(5) As Integer
      Dim tot, i As Integer
      array(0) = 3
     array(1) = 2
      array(2) = 1
      array(3) = 5
      array(4) = 6
      For i = 2 To 4
        tot = tot + array(i)
      Next
      calcula(tot)
      Console.WriteLine(tot)
     ...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Comandos De Programacion
  • Programación de comandos en shell
  • comandos
  • Comandos
  • Comandos
  • La comanda
  • comandos
  • comandos

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS