How can you get to only save all the modified tabs
By save i mean save as a text file or open your own savedialog < example :)

See if the following sample project helps about using a Tab's .Tag property.

Public Class Form1
   
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '// clear the default tabs.  should be done from designer mode. 
        For Each coolDefaultTab As TabPage In TabControl1.TabPages
            TabControl1.TabPages.Remove(coolDefaultTab)
        Next
        Button1.Text = "New File" : Button2.Text = "Open File" : Button3.Text = "Save File"
        '// check if tab is available, else add new tab.
        If TabControl1.TabPages.Count = 0 Then
            addNewTab()
        End If
    End Sub

    Private Sub addNewTab()
        Dim newTab As New TabPage
        newTab.Tag = "" '// used to determine which tab is accessing which file.
        newTab.Text = "New CodeOrder :)" '// add a title text to the new tab.
        Dim newRtb As New RichTextBox With {.Dock = DockStyle.Fill, .ForeColor = Color.SlateGray} '//design a richtextbox.
        newTab.Controls.Add(newRtb) '// add richtextbox to new tab.
        TabControl1.TabPages.Add(newTab) '// add new tab to tabcontrol.
        '// select the new tab.
        TabControl1.SelectedIndex = TabControl1.TabPages.Count - 1
        '// since newRtb is the first control added to your new tab, you will refer to it by Index, as "Controls(0)".
        TabControl1.SelectedTab.Controls(0).Select() '// select the richtextbox.
    End Sub

    '// New File.
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        addNewTab()
    End Sub

    '// Open File
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If TabControl1.TabPages.Count = 0 Then  '// if no tabs available, add new tab.
            addNewTab()
        End If
        '// get the appropriate richtextbox.
        Dim mySelectedRichtextbox As RichTextBox = TabControl1.SelectedTab.Controls(0)
        '// load a file.
        Dim coolOpenFileDialog As New OpenFileDialog
        If coolOpenFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
            Try
                '// load file.
                mySelectedRichtextbox.LoadFile(coolOpenFileDialog.FileName, RichTextBoxStreamType.RichText)
                '// add the full file path as the selected tab's tag.
                TabControl1.SelectedTab.Tag = coolOpenFileDialog.FileName
                '// add the file name to the selected tab's title.
                TabControl1.SelectedTab.Text = IO.Path.GetFileName(coolOpenFileDialog.FileName)
            Catch ex As Exception
                MsgBox("Cannot load file." & vbNewLine & vbNewLine & ex.Message, MsgBoxStyle.Critical)
            End Try
        End If
    End Sub

    '// Save File.
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If TabControl1.TabPages.Count = 0 Then Exit Sub '// check if tab is available.
        '// get the appropriate richtextbox.
        Dim mySelectedRichtextbox As RichTextBox = TabControl1.SelectedTab.Controls(0)
        '// check if the selected tab's file exists.
        If IO.File.Exists(TabControl1.SelectedTab.Tag) Then
            '// save file.
            mySelectedRichtextbox.SaveFile(TabControl1.SelectedTab.Tag, RichTextBoxStreamType.RichText)
        Else
            Dim coolSaveFileDialog As New SaveFileDialog
            coolSaveFileDialog.Filter = ".RTF ( rich text format )|*.rtf"
            If coolSaveFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
                '// save file.
                mySelectedRichtextbox.SaveFile(coolSaveFileDialog.FileName, RichTextBoxStreamType.RichText)
                '// add the file name to the selected tab's title.
                TabControl1.SelectedTab.Text = IO.Path.GetFileName(coolSaveFileDialog.FileName)
                '// confirm.
                MsgBox("File Saved.", MsgBoxStyle.Information)
            End If
        End If
    End Sub
End Class

As for modifying the text content, etc.

'// get the appropriate richtextbox.
        Dim mySelectedRichtextbox As RichTextBox = TabControl1.SelectedTab.Controls(0)
        '// run code. 
        '//Example: to Paste.
        mySelectedRichtextbox.Paste()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.