Ok, this is a little hard to explain, i basically am making a miniature operating system and there is a notepad feature. I am allowing a save in this operating system. I have a hidden button on the mainscreen than shows itself when the save is clicked on the notepad form. The problem is that I cannot figure out how to actually make it save. I need this button to be clicked, the notepad form to open (not a problem,) and the multiline textbox to have the same text as before. Any help would be appreciated. Thanks a lot

Recommended Answers

All 2 Replies

You lost me on your sequence of events. However, the simplest way to store the textbox is to use "UserSettings". Go to Project->Properties and select the Settings tab. Create three setting like these:

Then in your notepad form do something like this:

   Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
      My.Settings.SavedTBText = TextBox1.Text
      My.Settings.SavedTBSelectionStart = TextBox1.SelectionStart
      My.Settings.SavedTBSelectionLength = TextBox1.SelectionLength
   End Sub

   Private Sub Form_NotePad_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      With TextBox1
         .Text = My.Settings.SavedTBText
         .SelectionStart = My.Settings.SavedTBSelectionStart
         .SelectionLength = My.Settings.SavedTBSelectionLength
      End With
   End Sub

This will save/restore the state of the textbox on the notepad form.

Sorry to confuse you but this was all that I was looking for. I really appreciate it

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.