You are on page 1of 2

‘MENDOZA, ELVIN JOSEPH PUALENGCO

‘BS INFORMATION TECHNOLOGY


‘LABORATORY ACTIVITY #3

Imports System.IO

Public Class Form1


Dim SR As StreamReader
Dim PreColor(5) As String
Dim RetireColor(1) As String
Dim NewColor(2) As String
Dim Colors(6) As String

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


System.EventArgs) Handles MyBase.Load

SR = IO.File.OpenText("D:\PreColor.txt")
For i As Integer = 0 To PreColor.Length - 1
SR.Peek()
PreColor(i) = SR.ReadLine
Next
SR.Close()

SR = IO.File.OpenText("D:\RetireColor.txt")
For i As Integer = 0 To RetireColor.Length - 1
SR.Peek()
RetireColor(i) = SR.ReadLine
Next
SR.Close()

SR = IO.File.OpenText("D:\NewColor.txt")
For i As Integer = 0 To NewColor.Length - 1
SR.Peek()
NewColor(i) = SR.ReadLine
Next
SR.Close()

Dim n As Integer
n = (PreColor.Length - 1) - (RetireColor.Length - 1) +
(NewColor.Length - 1)
ReDim Preserve PreColor(n)

End Sub

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


System.EventArgs) Handles Button1.Click

For i As Integer = 0 To PreColor.Length - 1

For o As Integer = 0 To RetireColor.Length - 1

If PreColor(i) = RetireColor(o) Then


PreColor(i) = Nothing
End If
Next
Next

Dim x As Integer = 0

For i As Integer = 0 To PreColor.Length - 1

If PreColor(i) = Nothing Then


PreColor(i) = NewColor(x)
x = x + 1
End If

Next
Array.Sort(PreColor)
For i As Integer = 0 To PreColor.Length - 1
ListBox1.Items.Add(PreColor(i))
Next
End Sub
End Class

You might also like