特定の数値を他の形式に変換するアプリを作成しました
。
- 1 = A
- 2 = B
- 3 = C
- 4 = D
- 5 = エ
- 等
私はその機能を問題なく作成し、かなり長い間使用してきましたが、今では物事をより速くバッチで実行したいと考えています。
そのため、テキスト ファイルから Textbox1 にコピーし、button1 を押して textbox2 を他のテキスト ファイルにコピーするのは非常に困難です。
そのため、テキスト ファイルをリスト ボックスにロードしてから、そのリスト内の各項目を別のテキスト ファイルにエクスポートできる 2 番目のリストにループすることを考えていました。
インポートとエクスポートについては説明しましたが、行き詰まっているのはループを作成することです。
より良い方法を知っているか、この方法で修正する方法を教えてください。
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Using FD As New OpenFileDialog()
FD.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
If FD.ShowDialog = Windows.Forms.DialogResult.OK Then
ListBox1.Items.Clear()
ListBox1.Items.AddRange(IO.File.ReadAllLines(FD.FileName))
End If
End Using
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Do
Dim Item As String = ""
For Each i As String In ListBox1.Items
Item &= i
TextBox1.Text = Item
TextBox2.Text = MYFUNCTION(TextBox1.Text)
ListBox2.Items.Add(TextBox2.Text)
TextBox1.Text = ""
TextBox2.Text = ""
Next
Loop Until TextBox1.Text = "END"
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
'TextBox2.Text = MeidHexToDec(TextBox1.Text)
Using FD As New SaveFileDialog()
FD.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
If FD.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim FileContent As String = ""
For Each i As String In ListBox2.Items
FileContent &= i & vbCrLf
Next
IO.File.WriteAllText(FD.FileName, FileContent)
End If
End Using
End Sub
だから私の最終的な目標は、次のようなことをすることです:
TextFile1.txt
- 1
- 2
- 5
- 5
- 1
- 3
- 2
- 終わり
その後、変換出力の後
TextFile2.txt
- あ
- B
- え
- え
- あ
- C
- B
テキスト ファイルのサイズは、場合によっては 10 アイテムしかない場合もあれば、50 になる場合もあります... ありがとうございます。