You are on page 1of 3

Práctica 4: ListBox(), Vectores

Public Class Form1


Dim H(100) As Single
Dim ph(100) As Single
Dim poh(100) As Single
Dim AcumH As Single
Dim AcumpH As Single
Dim AcumpOH As Single
Dim n As Integer
Dim i As Integer
Dim no As Integer
Dim dato As Single

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles Button1.Click
no = Val(TextBox1.Text)

For i As Integer = 0 To no - 1

H(i) = Val(InputBox("ing. valor"))


ListBox1.Items.Add(H(i))
Next i

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles Button2.Click
ListBox1.Items.Remove(ListBox1.SelectedItem())

For i As Integer = 0 To ListBox1.Items.Count() - 1


H(i) = 0
H(i) = Val(ListBox1.Items.Item(i))
Next i

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles Button3.Click
n = ListBox1.Items.Count()

For i As Integer = 0 To n - 1
H(i) = Val(ListBox1.Items.Item(i))
ph(i) = -Math.Log10(H(i))
poh(i) = 14 - ph(i)
ListBox2.Items.Add(ph(i))
ListBox3.Items.Add(poh(i))
Next i

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles Button4.Click

AcumH = 0

For i As Integer = 0 To ListBox1.Items.Count() - 1


AcumH = AcumH + ListBox1.Items.Item(i)
Next i

AcumpH = 0

For i As Integer = 0 To ListBox2.Items.Count() - 1


AcumpH = AcumpH + ListBox2.Items.Item(i)
Next i

AcumpOH = 0

For i As Integer = 0 To ListBox3.Items.Count() - 1


AcumpOH = AcumpOH + ListBox3.Items.Item(i)
Next i

AcumH = AcumH / ListBox1.Items.Count()


AcumpH = AcumpH / ListBox2.Items.Count()
AcumpOH = AcumpOH / ListBox3.Items.Count()
TextBox2.Text = AcumH
TextBox3.Text = AcumpH
TextBox4.Text = AcumpOH

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles Button5.Click
ListBox1.Items.Clear()
ListBox2.Items.Clear()
ListBox3.Items.Clear()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""

End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button6.Click
End
End Sub
End Class

You might also like