Imports System.IO Imports System.Text.RegularExpressions Imports System.Text Public Class Form1 Private mFilePath As String = "C:\test.ini" Private iniData As XDocument Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load TextBox1.Text = "Section2" Button1.Text = "読み込み" End Sub Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click ListBox1.DataSource = ReadSection(mFilePath, TextBox1.Text) End Sub Private Function ReadSection(ByVal filePath As String, ByVal sectionName As String) As String() Dim rPattern As New Regex("^[[](?<X>.+)[]]$") Dim lst As New List(Of String)() Dim found As Boolean = False For Each row As String In File.ReadAllLines(filePath, Encoding.GetEncoding("Shift_JIS")) Dim m = rPattern.Match(row) If m.Success Then If found Then Exit For ElseIf m.Groups("X").Value = sectionName Then found = True End If ElseIf found Then lst.Add(row) End If Next Return lst.ToArray() End Function End Class