• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 418
  • Last Modified:

How will I get the saved history of textbox (text which is previously entered) in vb.net ?

How will I get the saved history of textbox (text which is previously entered)  in vb.net ?

Thanks in advance
0
hc_gupta
Asked:
hc_gupta
  • 2
1 Solution
 
Meir RivkinFull stack Software EngineerCommented:
u can use any available .Net data structure to store previous textbox values, like List, Queue, etc.
i'd create class like this:
    public class TextHistory
    {
        private List<string> history = new List<string>();
        public void Add(string text)
        {
            history.Add(text);
        }
        public IList<string> History
        {
            get { return history.AsReadOnly(); }
        }
    }

Open in new window

0
 
Meir RivkinFull stack Software EngineerCommented:
to use it simply add a member in your winform class.
public class MyForm : Form{
private TextHistory myHistory = new TextHistory();

}

Open in new window

each time user enter text call the Add function which the textbox.Text.
whenever u need to get all previous history, simply call the property History.
if u want a more generic history object which stores different types not only string, then u can use a generic form of the history class:
    public class GenericHistory<T>
    {
        private List<T> history = new List<T>();
        public void Add(T text)
        {
            history.Add(text);
        }
        public IList<T> History
        {
            get { return history.AsReadOnly(); }
        }
    }

Open in new window


now, to declare the type of the history class use this way, this example for integer:
public class MyForm : Form{
private GenericHistory<int> myHistory = new GenericHistory<int>();

}

Open in new window

0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now