Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer.Enabled = False
Progressbar.Value = 0
End Sub
Private Sub cmdsamenvoegen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsamenvoegen.Click
Dim lijn As String
Dim bestand1 As String
Dim bestand2 As String
Dim schrijflocatie As String
Dim postcode As Integer
Dim gemeentenaam As String
Dim id As Integer
Dim ID1 As Integer
Dim naam As String
Dim geslacht As String
Dim straatnr As String
Dim postcode2 As Integer
Dim resultaat As Integer
Dim teller As Integer
Dim naamsamengevoegd As String
Dim straatnrsamengevoegd As String
Dim postcodesamengevoegd As Integer
Dim gemeentenaamsamengevoegd As String
bestand1 = txtbestand1.Text
bestand2 = txtbestand2.Text
schrijflocatie = txtsamengevoegd.Text
FileOpen(1, bestand1, OpenMode.Input)
Dim tweedebestand As New FileStream(bestand2, FileMode.OpenOrCreate, FileAccess.Read)
Dim reader As New StreamReader(tweedebestand)
Dim wegschrijfbestand As New FileStream(schrijflocatie, FileMode.Open, FileAccess.Write)
Dim writer As New StreamWriter(wegschrijfbestand)
Do While Not EOF(1)
Input(1, ID1)
Input(1, postcode)
Input(1, gemeentenaam)
Loop
Do While Not reader.peek - 1
lijn = reader.ReadLine()
naam = lijn.Substring(0, 21)
geslacht = lijn.Substring(21, 1)
straatnr = CType(lijn.Substring(22, 30), String)
postcode2 = CType(lijn.Substring(52, 1), Integer)
Loop
For teller = 0 To 62
id = CType(teller.ToString.Substring(0, 1), Integer)
naamsamengevoegd = naam.Substring(2, 32)
straatnrsamengevoegd = CType(straatnr.ToString.Substring(34, 23), String)
postcodesamengevoegd = CType(postcode.ToString.Substring(59, 4), Integer)
gemeentenaamsamengevoegd = gemeentenaam.Substring(65, 20)
writer.WriteLine(lijn)
Next
Progressbar.Value = 0
Timer.Enabled = True
End Sub
Private Sub Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer.Tick
Progressbar.Value = Progressbar.Value + 1
If Progressbar.Value >= 100 Then _
Timer.Enabled = False
End Sub
Private Sub cmdbestand1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdbestand1.Click
Dim openbestand1 As New OpenFileDialog
If openbestand1.ShowDialog() = DialogResult.OK Then
txtbestand1.Text = openbestand1.FileName
End If
End Sub
Private Sub cmdbestand2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdbestand2.Click
Dim openbestand2 As New OpenFileDialog
If openbestand2.ShowDialog() = DialogResult.OK Then
txtbestand2.Text = openbestand2.FileName
End If
End Sub
Private Sub cmdbestand3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdbestand3.Click
Dim lol As String
Dim opslaanbestand3 As New OpenFileDialog
If opslaanbestand3.ShowDialog() = DialogResult.OK Then
txtsamengevoegd.Text = opslaanbestand3.FileName
End If
End Sub
End Class