You are on page 1of 12

Public Class Form1

Dim material(10) As String


Dim pesos(10) As Double
Dim cant As Integer
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim i As Integer

cant = Val(TextBox1.Text)
i = 0

ListBox1.Items.Add("material" & vbTab & "pesos")

Do
material(i) = InputBox("ingrese el monbre del material")
pesos(i) = Val(InputBox("ingrese el peso del material "))
ListBox1.Items.Add(material(i) & vbTab & pesos(i))
i = i + 1
Loop While i < cant

End Sub

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


Button2.Click
Dim p As Integer
Dim temp As Integer
Dim temp2 As String

For p = 0 To (cant - 1)
For d = (p + 1) To (cant - 1)
If pesos(d) < pesos(p) Then
temp = pesos(p)
pesos(p) = pesos(d)
pesos(d) = temp

temp2 = material(p)
material(p) = material(d)
material(d) = temp2

End If
Next
Next
For i = 0 To cant - 1
ListBox2.Items.Add(material(i) & vbTab & pesos(i))
Next

End Sub

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


Button3.Click
Dim p As Integer
Dim temp3 As Integer
Dim temp4 As String

For p = 0 To (cant - 1)
For d = (p + 1) To (cant - 1)
If pesos(d) > pesos(p) Then
temp3 = pesos(p)
pesos(p) = pesos(d)
pesos(d) = temp3

temp4 = material(p)
material(p) = material(d)
material(d) = temp4

End If
Next
Next
For i = 0 To cant - 1
ListBox3.Items.Add(material(i) & vbTab & pesos(i))
Next

End Sub

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


Button4.Click
Dim pmax, pmin As Double
Dim imax, imin As Integer

pmax = pesos(0)

For i = 0 To cant - 1
If pesos(i) > pmax Then
pmax = pesos(i)
imax = i
End If
Next

pmin = pesos(0)

For i = 0 To cant - 1
If pesos(i) < pmin Then
pmin = pesos(i)
imin = i
End If
Next
TextBox2.Text = material(imax) & "con" & pmax
TextBox3.Text = material(imin) & "con" & pmin
End Sub
End Class
Fuerzas
Public Class Form1
Dim cant As Integer
Dim masa As Double
Dim aceleraciones(10) As Double
Dim Fuerzas(10) As Double
Dim temp, temp1 As Double

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


Button2.Click
ListBox2.Items.Clear()
ListBox2.Items.Add("N°" & vbTab & "Aceleracion (m/s)" & vbTab & "Fuerza
[N]")

For i = 0 To cant - 1
For j = i + 1 To cant - 1
If Fuerzas(j) < Fuerzas(i) Then
temp = Fuerzas(i)
Fuerzas(i) = Fuerzas(j)
Fuerzas(j) = temp
temp1 = aceleraciones(i)
aceleraciones(i) = aceleraciones(j)
aceleraciones(j) = temp1
End If
Next
Next
For i = 0 To cant - 1
ListBox2.Items.Add(i + 1 & vbTab & aceleraciones(i) & vbTab &
Fuerzas(i))
Next
End Sub

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


Button3.Click
ListBox3.Items.Clear()
ListBox3.Items.Add("N°" & vbTab & "Aceleracion (m/s)" & vbTab & "Fuerza
[N]")

For i = 0 To cant - 1
For j = i + 1 To cant - 1
If Fuerzas(j) > Fuerzas(i) Then
temp = Fuerzas(i)
Fuerzas(i) = Fuerzas(j)
Fuerzas(j) = temp
temp1 = aceleraciones(i)
aceleraciones(i) = aceleraciones(j)
aceleraciones(j) = temp1
End If
Next
Next
For i = 0 To cant - 1
ListBox3.Items.Add(i + 1 & vbTab & aceleraciones(i) & vbTab &
Fuerzas(i))
Next
End Sub

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


Button4.Click
Dim fmax, fmin As Double
Dim imax, imin As Integer

fmax = Fuerzas(0)
fmin = Fuerzas(0)

For i = 0 To cant - 1
If Fuerzas(i) > fmax Then
fmax = Fuerzas(i)
imax = i
End If
If Fuerzas(i) < fmin Then
fmin = Fuerzas(i)
imin = i
End If
Next
TextBox3.Text = fmax
TextBox4.Text = fmin

End Sub

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


Button1.Click
cant = Val(TextBox1.Text)
masa = Val(TextBox2.Text)
ListBox1.Items.Clear()
ListBox1.Items.Add("N°" & vbTab & "Aceleracion (m/s)" & vbTab & "Fuerza
[N]")

For i = 0 To cant - 1
aceleraciones(i) = Val(InputBox("Ingrese la Aceleracion"))
Fuerzas(i) = aceleraciones(i) * masa
ListBox1.Items.Add(i + 1 & vbTab & aceleraciones(i) & vbTab &
Fuerzas(i))
Next
End Sub
End Class
Public Class Form1

Dim materiales(10) As String


Dim pesos(10) As Double
Dim cant As Integer
Dim temp As Double
Dim temp1 As String

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


Button1.Click

ListBox1.Items.Add("Material" & vbTab & "Peso")


ListBox1.Items.Add("__________________________")
cant = Val(TextBox1.Text)

For i = 0 To cant - 1
materiales(i) = InputBox("Material")
pesos(i) = InputBox("Peso")
ListBox1.Items.Add(materiales(i) & vbTab & pesos(i))

Next
End Sub

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


Button2.Click

ListBox2.Items.Add("Material" & vbTab & "Peso")


ListBox2.Items.Add("__________________________")

For i = 0 To cant - 1
For j = i + 1 To cant - 1
If pesos(j) < pesos(i) Then
temp = pesos(i)
pesos(i) = pesos(j)
pesos(j) = temp
temp1 = materiales(i)
materiales(i) = materiales(j)
materiales(j) = temp1

End If
Next
Next
For i = 0 To cant - 1
ListBox2.Items.Add(materiales(i) & vbTab & pesos(i))
Next
End Sub

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


Button3.Click
ListBox3.Items.Add("Material" & vbTab & "Peso")
ListBox3.Items.Add("__________________________")

For i = 0 To cant - 1
For j = i + 1 To cant - 1
If pesos(j) > pesos(i) Then
temp = pesos(i)
pesos(i) = pesos(j)
pesos(j) = temp
temp1 = materiales(i)
materiales(i) = materiales(j)
materiales(j) = temp1

End If
Next
Next
For i = 0 To cant - 1
ListBox3.Items.Add(materiales(i) & vbTab & pesos(i))
Next
End Sub

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


Button4.Click
Dim pmax, pmin As Double
Dim imax, imin As Integer

pmax = pesos(0)
pmin = pesos(0)

For i = 0 To cant - 1
If pesos(i) > pmax Then
pmax = pesos(i)
imax = i
End If
If pesos(i) < pmin Then
pmin = pesos(i)
imin = i
End If
Next
TextBox2.Text = materiales(imax) & " con " & pesos(imax)
TextBox3.Text = materiales(imin) & " con " & pesos(imin)

End Sub
End Class
Public Class Form1
Dim cant As Integer
Dim distancia As Double
Dim nombres(10) As String
Dim tiempo(10) As Double
Dim velocidad(10) As Double
Dim prom, sum As Double

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


Button2.Click
Dim primer As Double
Dim ultimo As Double
Dim ip, iu As Integer

sum = 0
ip = tiempo(0)
iu = tiempo(0)

For j = 0 To cant - 1
sum = sum + tiempo(j)

If tiempo(j) < primer Then


primer = tiempo(j)
ip = j
End If
Next

For j = 0 To cant - 1
sum = sum + tiempo(j)

If tiempo(j) > ultimo Then


primer = tiempo(j)
iu = j
End If
prom = sum / cant
TextBox3.Text = nombres(ip)
TextBox4.Text = nombres(iu)
TextBox5.Text = prom
Next
End Sub

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


Button1.Click

cant = Val(TextBox1.Text)
distancia = Val(TextBox2.Text)
ListBox1.Items.Add("NOMBRE" & vbTab & "TIEMPO" & vbTab & "VELOCIDAD")

For i = 0 To cant - 1
nombres(i) = InputBox("NOMBRE")
tiempo(i) = InputBox("tiempo")
velocidad(i) = distancia / tiempo(i)
ListBox1.Items.Add(nombres(i) & vbTab & tiempo(i) & vbTab &
velocidad(i))

Next
End Sub
End Class
Matrices

Public Class Form1

Dim MA(5, 5) As Integer


Dim MB(5, 5) As Integer
Dim MC(5, 5) As Integer

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


Button1.Click

'llenar Matriz
For fil = 0 To 4
For col = 0 To 4
MA(fil, col) = Int(InputBox("A[" & fil & "][" & col & "]:"))

Next
Next

Const j = 0
For fil = 0 To 4
ListBox1.Items.Add(MA(fil, j) & vbTab & MA(fil, j + 1) & vbTab & MA(fil,
j + 2) & vbTab & MA(fil, j + 3) & vbTab & MA(fil, j + 4))

Next

For fil = 0 To 4
For col = 0 To 4
MB(fil, col) = Int(InputBox("B[" & fil & "][" & col & "]:"))

Next
Next

For fil = 0 To 4
ListBox2.Items.Add(MB(fil, j) & vbTab & MB(fil, j + 1) & vbTab & MB(fil,
j + 2) & vbTab & MB(fil, j + 3) & vbTab & MB(fil, j + 4))

Next

End Sub

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


Button2.Click

Dim OP As Integer
Dim prod As Integer
prod = 0

OP = ComboBox1.SelectedIndex
ListBox3.Items.Clear()

Const j = 0

Select Case OP
Case 0
For fil = 0 To 4
For col = 0 To 4

MC(fil, col) = MA(fil, col) + MB(fil, col)

Next
Next

For i = 0 To 4

ListBox3.Items.Add(MC(i, j) & vbTab & MC(i, j + 1) & vbTab &


MC(i, j + 2) & vbTab & MC(i, j + 3) & vbTab & MC(i, j + 4))

Next

Case 1
For fil = 0 To 4
For col = 0 To 4

MC(fil, col) = MA(fil, col) - MB(fil, col)

Next
Next

For i = 0 To 4

ListBox3.Items.Add(MC(i, j) & vbTab & MC(i, j + 1) & vbTab &


MC(i, j + 2) & vbTab & MC(i, j + 3) & vbTab & MC(i, j + 4))

Next

Case 2
For fil = 0 To 4
For col = 0 To 4
For k = 0 To 4
prod = MA(fil, k) * MB(k, col) + prod

Next
MC(fil, col) = prod
'prod = 0
Next
Next

For i = 0 To 4

ListBox3.Items.Add(MC(i, j) & vbTab & MC(i, j + 1) & vbTab &


MC(i, j + 2) & vbTab & MC(i, j + 3) & vbTab & MC(i, j + 4))

Next

End Select
End Sub

End Class
RESTA DE MATRICES :

Public Class Form1


Dim a(4, 5) As Integer
Dim at(5, 4) As Integer
Dim ai(4, 5) As Integer

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


Button1.Click

For fil = 0 To 3
For col = 0 To 4
a(fil, col) = Val(InputBox("a[" & fil & "][" & col & "]="))
Next
Next

Const j = 0

For fil = 0 To 3

ListBox1.Items.Add(a(fil, j) & vbTab & a(fil, j + 1) & vbTab & a(fil, j


+ 2) & vbTab & a(fil, j + 3) & vbTab & a(fil, j + 4))
Next

End Sub

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


Button2.Click
For fil = 0 To 4
For col = 0 To 3
at(col, fil) = a(fil, col)
Next
Next

Const j = 0

For fil = 0 To 4

ListBox2.Items.Add(at(fil, j) & vbTab & at(fil, j + 1) & vbTab & at(fil,


j + 2) & vbTab & at(fil, j + 3))
Next

For fil = 0 To 4
For col = 0 To 3
If fil = col Then
ai(fil, col) = 1
Else
ai(fil, col) = 0

End If
Next
Next
For fil = 0 To 3

ListBox3.Items.Add(ai(fil, j) & vbTab & ai(fil, j + 1) & vbTab & ai(fil,


j + 2) & vbTab & ai(fil, j + 3) & vbTab & ai(fil, j + 4))
Next
End Sub
End Class

You might also like