Option Explicit On Option Strict On Option Infer On Imports System Imports System.Collections.Generic Imports System.IO Imports System.Linq Module Module1 Sub Main() Dim uidList = ReadUids().ToList() Console.WriteLine("[Read UIDs]") For Each uid In uidList Console.WriteLine($" <{uid}>") Next Console.WriteLine() Console.WriteLine("[Input UIDs]") While True Dim uid = Console.ReadLine() If uid Is Nothing Then Exit While uidList.Add(uid) End While Console.WriteLine() Console.WriteLine("[Write UIDs]") For Each uid In uidList Console.WriteLine($" <{uid}>") Next WriteUids(uidList.Distinct().ToArray()) ' 一応,Distinctかけて一意にしておく。 End Sub Function ReadUids() As String() If Not File.Exists("uid.dat") Then Return Array.Empty(Of String) End If Return File.ReadAllLines("uid.dat") End Function Sub WriteUids(uids As String()) File.WriteAllLines("uid.dat", uids) End Sub End Module