Solved

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

Posted on 2013-05-29
4
373 Views
Last Modified: 2013-07-07
How will I get the saved history of textbox (text which is previously entered)  in vb.net ?

Thanks in advance
0
Comment
Question by:hc_gupta
  • 2
4 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 39204478
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
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39204501
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now