-
March 24th, 2019, 11:58 AM
#1
Checkboxs as text filter
Vb 2015
I trying to make some text filters whit checkbox
My program read text files and sort the events line by line, but i want to hide sertain lines whit text if i uncheck the checkbox.
There is multible checkbox`s box1 hide line whit aaa
box2 bbb etc
Code:
Imports System.IO
Public Class MainForm
Private Sub RadioButton5_CheckedChanged(sender As Object, e As EventArgs)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub AvsluttToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AvsluttToolStripMenuItem.Click
End
End Sub
Private Sub OmToolStripMenuItem_Click(ByVal sender As Object, e As EventArgs) Handles OmToolStripMenuItem.Click
Dim NewForm As New About
NewForm.Show()
End Sub
Private Sub HelpToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles HelpToolStripMenuItem.Click
Dim Newform As New Changelog
Newform.Show()
End Sub
Private Sub PrintToolStripMenuItem_Click(sender As Object, e As EventArgs)
End Sub
Private Sub ÅpneToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ÅpneToolStripMenuItem.Click
If (ÅpneFil.ShowDialog = DialogResult.OK) Then
RichTextBox.Text = My.Computer.FileSystem.ReadAllText(ÅpneFil.FileName)
End If
End Sub
Private Sub RichTextBox_TextChanged(sender As Object, e As EventArgs) Handles RichTextBox.TextChanged
End Sub
Private Sub Button_Click(sender As Object, e As EventArgs) Handles VelgFil.Click
If (ÅpneFil.ShowDialog = DialogResult.OK) Then
RichTextBox.Text = My.Computer.FileSystem.ReadAllText(ÅpneFil.FileName)
RichTextBox.Text = Trim(RichTextBox.Text.Replace(vbLf, "").Replace(vbCr, " "))
RichTextBox.Text = Trim(RichTextBox.Text.Replace("---", vbLf))
Dim richtxt As String = RichTextBox.Text
Dim pos As Integer = richtxt.IndexOf(vbCr)
RichTextBox.Text = richtxt.Substring(pos + 1, richtxt.Length - pos - 1)
End If
End Sub
Private Sub OpenFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles ÅpneFil.FileOk
Filebane.Text = ÅpneFil.FileName
End Sub
Private Sub Filebane_TextChanged(sender As Object, e As EventArgs) Handles Filebane.TextChanged
End Sub
Private Sub ExportToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExportToolStripMenuItem.Click
LagreFil.ShowDialog()
End Sub
Private Sub Menyer_ItemClicked(sender As Object, e As ToolStripItemClickedEventArgs) Handles Menyer.ItemClicked
End Sub
Private Sub BindingSource1_CurrentChanged(sender As Object, e As EventArgs)
End Sub
Private Sub LagreFil_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles LagreFil.FileOk
Dim ExportNavn As String = LagreFil.FileName
Dim objektwriter As New System.IO.StreamWriter(ExportNavn)
objektwriter.Write(RichTextBox.Text)
objektwriter.Close()
End Sub
Private Sub OptionToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles OptionToolStripMenuItem.Click
Dim NewForm As New Innstillinger
NewForm.Show()
End Sub
Private Sub SkrivUtToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SkrivUtToolStripMenuItem.Click
SkrivUt.ShowDialog()
End Sub
Private Sub CheckBox5_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox5.CheckedChanged
End Sub
End Class
-
March 25th, 2019, 10:45 PM
#2
Re: Checkboxs as text filter
Well if you were to read the file line by line when placing it into the text box it would be fairly simple to omit the lines you do not want to show but you are adding them all at once so that means you would need to go through them and remove the ones you do not want to show.
I have not used the rich text box in VB.Net so not sure if it supports a method to reference a specific line and remove it or not. Probably does but I have not looked to see for sure
Always use [code][/code] tags when posting code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|