Visual Studio 2012-Matriz Con Punteros Y Funciones Protegido Sin DataGridView Utilizando ListBox y TextBox
Visual Studio 2012-Matriz Con Punteros Y Funciones Protegido Sin DataGridView Utilizando ListBox y TextBox
Visual Studio 2012-Matriz Con Punteros Y Funciones Protegido Sin DataGridView Utilizando ListBox y TextBox
Manab
1. Procedimiento
Definicin
Llamar a un procedimiento
Los procedimientos se invocan desde otras partes del cdigo. Esto se conoce como una
llamada a procedimiento. Cuando finaliza la ejecucin de un procedimiento, ste devuelve el
control al cdigo que lo invoc, que recibe el nombre de cdigo de llamada. El cdigo de
llamada es una instruccin o una expresin contenida en una instruccin, que hace referencia
al procedimiento por su nombre y le transfiere el control.
Tipos de procedimientos
operador estndar cuando uno o los dos operandos son una clase definida
pasar tipos de datos especficos cada vez que realiza una llamada.
Como crear un procedimiento en Visual Basic
Si tiene un cdigo que realiza la misma tarea en distintos lugares, puede escribir la tarea una
vez como procedimiento y llamarlo despus desde distintos lugares del cdigo.
Fuera de cualquier otro procedimiento, utilice una instruccin Sub, seguida de una instruccin
End Sub.
En la instruccin Sub, agregue detrs de la palabra clave Sub el nombre del procedimiento y, a
continuacin, la lista de parmetros entre parntesis.
Coloque las instrucciones del cdigo del procedimiento entre las instrucciones Sub y End Sub
Fuera de cualquier otro procedimiento, utilice una instruccin Function, seguida de una
instruccin End Function.
Coloque las instrucciones de cdigo del procedimiento entre las instrucciones Function y End
Function.
repetitivos
Asegrese de que define el nuevo procedimiento en un lugar donde el cdigo anterior tiene
acceso a l.
3. Procedimiento experimental
Agregamos los elementos necesarios para el Programa con ByVal y ByRef, ingresando el
cdigo necesario para su correcta ejecucin
5. Conclusiones
Las funciones y procedimientos nos ayudan a encontrar rpidamente un error sin necesidad
de adentrarnos a todo el programa, y es muy utilizado ya que facilita demasiados procesos
que requieres una cadena de cdigo en cambio podemos disponer de este sin necesidad de
irlo revisando todo.
6. Anexos
Programa 1.
Realizar una Matriz que permita:
1. ingreso aleatorio
2. rango del 1 al 100
3. y que me permita buscar un numero en la n posicin
4. sumar los valores
5. sacar promedio
6. buscar el nmero mayor y menos
9. no se repite el ingreso de los valores
10. ordenar de forma ascendente y descendente
11. Realizar un ejercicio que toda vaya en funciones o procedimientos.
Next
Next
ListBox3.Items.Add(vo(it))
Next
For it = 1 To mult
ListBox2.Items.Add(vo(it))
ListBox2.Sorted = True
Next
For i = 1 To y
If x >= 1 And x <= 9 And y >= 1 And y <= 9 Then
If x = 9 And y = 9 Then
ListBox1.Items.Add(Str(m(i, 1)) & Str(m(i, 2)) & " " &
Str(m(i, 3)) & " " & Str(m(i, 4)) & " " & Str(m(i, 5)) & " " & Str(m(i, 6)) & " "
& Str(m(i, 7)) & " " & Str(m(i, 8)) & " " & Str(m(i, 9)))
End If
If x = 8 And y = 8 Then
ListBox1.Items.Add(Str(m(i, 1)) & Str(m(i, 2)) & " " &
Str(m(i, 3)) & " " & Str(m(i, 4)) & " " & Str(m(i, 5)) & " " & Str(m(i, 6)) & " "
& Str(m(i, 7)) & " " & Str(m(i, 8)))
End If
If x = 7 And y = 7 Then
ListBox1.Items.Add(Str(m(i, 1)) & Str(m(i, 2)) & " " &
Str(m(i, 3)) & " " & Str(m(i, 4)) & " " & Str(m(i, 5)) & " " & Str(m(i, 6)) & " "
& Str(m(i, 7)))
End If
If x = 6 And y = 6 Then
ListBox1.Items.Add(Str(m(i, 1)) & Str(m(i, 2)) & " " &
Str(m(i, 3)) & " " & Str(m(i, 4)) & " " & Str(m(i, 5)) & " " & Str(m(i, 6)))
End If
If x = 5 And y = 5 Then
ListBox1.Items.Add(Str(m(i, 1)) & Str(m(i, 2)) & " " &
Str(m(i, 3)) & " " & Str(m(i, 4)) & " " & Str(m(i, 5)))
End If
If x = 4 And y = 4 Then
ListBox1.Items.Add(Str(m(i, 1)) & Str(m(i, 2)) & " " &
Str(m(i, 3)) & " " & Str(m(i, 4)))
End If
If x = 3 And y = 3 Then
ListBox1.Items.Add(Str(m(i, 1)) & Str(m(i, 2)) & " " &
Str(m(i, 3)))
End If
If x = 2 And y = 2 Then
ListBox1.Items.Add(Str(m(i, 1)) & Str(m(i, 2)))
End If
End If
Next
For i = 1 To y
For j = 1 To y
If nmy < m(i, j) Or nmy > m(y, y) Then
vmayor = Math.Max(Convert.ToDouble(nmy),
Convert.ToDouble(m(i, j)))
nmy = vmayor
s = s + m(i, j)
End If
Next
Next
txtmayorm.Text = nmy
txtmenorm.Text = vmenor
promedio(z)
lblsuma.Text = (z)
End Sub
Sub suma(ByVal m As Integer, ByVal n As Integer, ByVal o As Integer)
z += o
End Sub
Sub promedio(ByRef prom As Double)
Dim mult As Double
mult = a * b
g = prom / mult
txtpromediom.Text = g
End Sub
Private Sub ListBox1_Enter(sender As Object, e As EventArgs) Handles
ListBox1.Enter
End Sub
End Sub
End Class