Imports System.IO Public Class Form2 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim sr As New StreamReader("BookMark.txt", System.Text.Encoding.Default) While (sr.EndOfStream = False) Dim line As String line = sr.ReadLine ListBox1.Items.Add(line) End While sr.Close() End Sub Private Sub ListBox1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick Form1.WebBrowser1.Navigate(ListBox1.SelectedItem) End Sub Private Sub ButtonAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonAdd.Click With ListBox1 'リストボックスに追加 .Items.Add(TextBox1.Text) .Items.Add(Form1.WebBrowser1.Url) 'お気に入りの数を取得 Dim src As New StreamReader("BMCount.txt", System.Text.Encoding.Default) Dim count As Integer = Integer.Parse(src.ReadLine) src.Close() count += 1 'お気に入りの数-1+2でListBoxの数を求める .SelectedIndex = 0 '選択の初期化 '書き込み Dim sw As New StreamWriter("BookMark.txt", False, System.Text. _ Encoding.Default) Do Until .SelectedIndex = count sw.WriteLine(.SelectedItem) .SelectedIndex += 1 Loop sw.WriteLine(.SelectedItem) sw.Close() 'カウンタを増やす count += 1 Dim swc As New StreamWriter("BMCount.txt", False, System.Text. _ Encoding.Default) swc.WriteLine(count.ToString) swc.Close() End With End Sub End Class