Solved

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

Posted on 2013-05-29
4
376 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

816 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

10 Experts available now in Live!

Get 1:1 Help Now