开发者

How to append text pending on checkbox state?

开发者 https://www.devze.com 2023-01-24 22:11 出处:网络
I’m making a form with a checkbox where if checked a target file is appended with text-A and if Unchecked the file is appended with text-B

I’m making a form with a checkbox where if checked a target file is appended with text-A and if Unchecked the file is appended with text-B

How can I do this?

what i have sofar:

    Private Sub CheckBox1_Checked(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox1.Checked
    Dim FILE_NAME As String = "C:\ANSWERSLIST.txt"

    'Adding items for AutoCAD 2006...
    If System.IO.File.Exists(FILE_NAME) = True Then
        Dim objWriter As New System.IO.StreamWriter(FILE_NAME, True)
        objWriter.WriteLine("YES")
 开发者_高级运维       objWriter.Close()
    End If
End Sub


You could use the AppendAllText method:

If MyCheckBox.IsChecked Then
    File.AppendAllText("foo.txt", "text-A")
Else
    File.AppendAllText("foo.txt", "text-B")
End If
0

精彩评论

暂无评论...
验证码 换一张
取 消