0% found this document useful (0 votes)
40 views7 pages

Programación de Vectores y Matrices.

The document contains examples of using arrays in Visual Basic code. It includes 6 exercises demonstrating how to: 1) Populate and display a one-dimensional array in a list box, 2) Populate a two-dimensional array and display it in a data grid view, 3) Search a two-dimensional array and populate combo boxes with matches, 4) Populate a one-dimensional array with user input numbers and count even and odd numbers, 5) Populate and sum a two-dimensional array displayed in a data grid view, and 6) Search a two-dimensional array for negative numbers and populate a combo box with the results. The arrays are used to store and manipulate student names and grades.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views7 pages

Programación de Vectores y Matrices.

The document contains examples of using arrays in Visual Basic code. It includes 6 exercises demonstrating how to: 1) Populate and display a one-dimensional array in a list box, 2) Populate a two-dimensional array and display it in a data grid view, 3) Search a two-dimensional array and populate combo boxes with matches, 4) Populate a one-dimensional array with user input numbers and count even and odd numbers, 5) Populate and sum a two-dimensional array displayed in a data grid view, and 6) Search a two-dimensional array for negative numbers and populate a combo box with the results. The arrays are used to store and manipulate student names and grades.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Guía de ejercicios “Array’s”

Clase.

Estructura de Datos

Catedrático.

Ing. David Ordoñez.

Presentado por.

Estrella Bellaluna Silva Alemán.

116070088

Tocoa, Colon C.A

8/04/2018
Ejercicio N°1

Public Class Form1


Dim vector(24) As String

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles


Button1.Click

vector(0) = "Chelsea"
vector(1) = "Jenifer"
vector(2) = "Maria"
vector(3) = "Estrella"
vector(4) = "Yessica"
vector(5) = "Raquel"

vector(6) = "Bella"
vector(7) = "Luna"
vector(8) = "Marbella"
vector(9) = "Sonia"
vector(10) = "Sofia"
vector(11) = "Mireydi"

vector(12) = "Eduardo"
vector(13) = "Edwin"
vector(14) = "Rogel"
vector(15) = "Erickson"
vector(16) = "Alex"
vector(17) = "Javier"

vector(18) = "Rolvin"
vector(19) = "ALesander"
vector(20) = "Mario"
vector(21) = "Luis"
vector(22) = "Brayan"
vector(23) = "Dicarthy"
vector(24) = "Jefrik"

For x = 0 To 24
ListBox1.Items.Add(vector(x))
Next
End Sub

End Class
Ejercicio N°2

Public Class Form1


Dim Alumnos(5, 5) As String

Dim c As Integer
Dim l As Integer

Private Sub Form1_Load(sender As Object, e As EventArgs)


Handles
MyBase.Load

DataGridView1.Columns.Add("Fisica2", "Fisica II")


DataGridView1.Columns.Add("Estructura", "Estrutura de Datos")
DataGridView1.Columns.Add("DiseñoSistema", "Diseño de
Sistema")
DataGridView1.Columns.Add("Algebra", "Algebra Lineal")
DataGridView1.Columns.Add("Ingles", "Ingles V")

For i = 1 To 4
DataGridView1.Rows.Add()
Next

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs)


Handles
Button1.Click

If c <= 4 Then
Alumnos(l, c) = TextBox1.Text
DataGridView1.Rows(l).Cells(c).Value = Alumnos(l, c)

Else
l = l + 1
c = 0
Alumnos(l, c) = TextBox1.Text
DataGridView1.Rows(l).Cells(c).Value = Alumnos(l, c)
End If

c = c + 1

End Sub
End Class
Ejercicio N°3

For li = 0 To 4
For co = 0 To 4
If Alumnos(Li, co) = TextBox2.Text Then

ComboBox1.Items.Add(co)
ComboBox2.Items.Add(li)

ComboBox3.Items.Add(Alumnos(0, co))

End If
Next
Next
Ejercicio N°4
Public Class Form1

Dim Vector(19) As Integer


Dim C As Integer
Dim P As Integer
Dim I As Integer
Private Sub Form1_Load(sender As Object, e As
EventArgs) Handles MyBase.Load

End Sub

Private Sub Button1_Click(sender As Object, e As


EventArgs) Handles Button1.Click

'Codigo para guardar dentro del vector

If C <= 20 Then
Vector(C) = Val(TextBox1.Text)
ListBox1.Items.Add(Vector(C))
End If

C = C + 1

End Sub

Private Sub Button2_Click(sender As Object, e As


EventArgs) Handles Button2.Click
'Codigo para buscar numeros pares e impares
For x = 0 To 19
If Vector(x) Mod 2 = 0 Then
P = P + 1
Else
I = I + 1
End If
Next
TextBox2.Text = P
TextBox3.Text = I
End Sub
End Class
Ejercicio N°5
Public Class Form1

Dim Matriz(10, 6) As Integer

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles


Button1.Click
Dim c As Integer
Dim l As Integer

If c <= 5 Then
Matriz(l, c) = TextBox1.Text
DataGridView1.Rows(l).Cells(c).Value = Matriz(l, c)
Else
l = l + 1
c = 0
Matriz(l, c) = Val(TextBox1.Text)
DataGridView1.Rows(l).Cells(c).Value = Matriz(l, c)
End If
c = c + 1

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


DataGridView1.Columns.Add("Col1", "Columna 1")
DataGridView1.Columns.Add("Col2", "Columna 2")
DataGridView1.Columns.Add("Col3", "Columna 3")
DataGridView1.Columns.Add("Col4", "Columna 4")
DataGridView1.Columns.Add("Col5", "Columna 5")
DataGridView1.Columns.Add("Col6", "Columna 6")

For i = 1 To 9
DataGridView1.Rows.Add()
Next
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles


Button2.Click
Dim sf As Integer
Dim sc As Integer
For f = 0 To 9
For col = 0 To 5
sf = sf + Matriz(f, col)
Next
ComboBox1.Items.Add(sf)
sf = 0
Next

For col = 0 To 5
For f = 0 To 9
sc = sc + Matriz(f, col)
Next
ComboBox2.Items.Add(sc)
sc = 0
Next
End Sub
End Clas
Ejercicio N°6

Dim NI As Integer
For s = 0 To 9
For a = 0 To 5
If Matriz(s, a) < 0 Then
NI = Matriz(s, a)
ComboBox3.Items.Add(NI)
End If
Next
Next

For li = 0 To 4
For co = 0 To 4
If Alumnos(Li, co) =
TextBox3.Text Then

ComboBox1.Items.Add(co)
ComboBox2.Items.Add(Li)

End If
Next

Next

You might also like