Retaining Last Value in the Text Boxes in VB.NET

S

Suresh Kumaran

How do you retain the last value the user keyed in a text
box? I should be able to show the values when the user
runs the executable for the second time.

Appreciate help.


Suresh
 
D

Dmitriy Lapshin [C# / .NET MVP]

Suresh,

See, there is no single "best" option. I could just give some examples on
which way fits best the nature of the application:

a) An "Options" dialog box of a desktop application. Usually settings are
stored in the registry or in a configuration file. Please refer to the
Microsoft.Win32.Registry class and to the System.Configuration namespace for
more detailed information and examples.

b) A "Preferences" web page of a Web application. Web applications most
often work with some kind of database and usually store all information
within the database. Please refer to the System.Data namespace documentation
for more info and examples.

c) Customer details in a desktop CRM application. Such complex applications
also usually rely on some kind of database or structured storage.

P.S. In fact, the question you are asking is too "broadband". I suggest you
are facing a particular problem, and if you would describe things you want
to achieve, I think the community could came up with more detailed advice.
 
S

Suresh Kumaran

Dmitriy,

Thanks for your reply.

All right, here's what I want. My application is being
developed using VB.NET The design is this.

A. Form 1 designed for user to enter the part number. Form
1 has two buttons "Okay" and "Cancel" If the user
clicks "Okay", a textfile is validated and read for the
details of the partnumber,and the part number is passed as
aparameter to form 2.

B. Form 2 shows all other details of the partnumber such
as drawing date, approved date, description etc. These
values are placed on Form 2. Three button are availableon
form 2, "SAVE" "CANCEL" "EXIT" The user is allowed to
change any other details of the part number other than the
part number. User changes any details saves and exit the
application.

The requirement is that, if the user comes back the
application the second time around. I should be able to
show the partnumber he/she was working on in the Form 1.

How do I retain this value and show it?

Hope I have explained.

Suresh

-----Original Message-----
Suresh,

See, there is no single "best" option. I could just give some examples on
which way fits best the nature of the application:

a) An "Options" dialog box of a desktop application. Usually settings are
stored in the registry or in a configuration file. Please refer to the
Microsoft.Win32.Registry class and to the
System.Configuration namespace for
more detailed information and examples.

b) A "Preferences" web page of a Web application. Web applications most
often work with some kind of database and usually store all information
within the database. Please refer to the System.Data namespace documentation
for more info and examples.

c) Customer details in a desktop CRM application. Such complex applications
also usually rely on some kind of database or structured storage.

P.S. In fact, the question you are asking is too "broadband". I suggest you
are facing a particular problem, and if you would describe things you want
to achieve, I think the community could came up with more detailed advice.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Suresh Kumaran said:
Dmitriy,

What would be the best option to do this? Do you have a
sample coding on this?

Thanks in advance,

Suresh

.
 
S

Suresh Kumaran

Dmitriy,

Thanks for your reply. My choice was a text file too. Just
curious to know how do you code the values to the
registry? Do you have a sample. 'Cos I have not written
any codes before to write to the registry. Also won't the
registry cause a security issue when deploying the project?

Suresh
-----Original Message-----
Suresh,

Now I see. I think registry or a simple text file would be the best choice
here. When the user closes the Form 1, read the text box value and save it
to the registry/file with the appropriate Framework classes. And upon Form 1
start-up, check whether you have previously stored value and pre-populate
the text box.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Suresh Kumaran said:
Dmitriy,

Thanks for your reply.

All right, here's what I want. My application is being
developed using VB.NET The design is this.

A. Form 1 designed for user to enter the part number. Form
1 has two buttons "Okay" and "Cancel" If the user
clicks "Okay", a textfile is validated and read for the
details of the partnumber,and the part number is passed as
aparameter to form 2.

B. Form 2 shows all other details of the partnumber such
as drawing date, approved date, description etc. These
values are placed on Form 2. Three button are availableon
form 2, "SAVE" "CANCEL" "EXIT" The user is allowed to
change any other details of the part number other than the
part number. User changes any details saves and exit the
application.

The requirement is that, if the user comes back the
application the second time around. I should be able to
show the partnumber he/she was working on in the Form 1.

How do I retain this value and show it?

Hope I have explained.

Suresh

-----Original Message-----
Suresh,

See, there is no single "best" option. I could just
give
some examples on
which way fits best the nature of the application:

a) An "Options" dialog box of a desktop application. Usually settings are
stored in the registry or in a configuration file.
Please
refer to the
Microsoft.Win32.Registry class and to the
System.Configuration namespace for
more detailed information and examples.

b) A "Preferences" web page of a Web application. Web applications most
often work with some kind of database and usually store all information
within the database. Please refer to the System.Data namespace documentation
for more info and examples.

c) Customer details in a desktop CRM application. Such complex applications
also usually rely on some kind of database or
structured
storage.
P.S. In fact, the question you are asking is too "broadband". I suggest you
are facing a particular problem, and if you would describe things you want
to achieve, I think the community could came up with
more
detailed advice.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Dmitriy,

What would be the best option to do this? Do you have a
sample coding on this?

Thanks in advance,

Suresh

.

.
 
M

Michael Lang

Dmitriy,

Thanks for your reply.

All right, here's what I want. My application is being
developed using VB.NET The design is this.

A. Form 1 designed for user to enter the part number. Form
1 has two buttons "Okay" and "Cancel" If the user
clicks "Okay", a textfile is validated and read for the
details of the partnumber,and the part number is passed as
aparameter to form 2.

B. Form 2 shows all other details of the partnumber such
as drawing date, approved date, description etc. These
values are placed on Form 2. Three button are availableon
form 2, "SAVE" "CANCEL" "EXIT" The user is allowed to
change any other details of the part number other than the
part number. User changes any details saves and exit the
application.

The requirement is that, if the user comes back the
application the second time around. I should be able to
show the partnumber he/she was working on in the Form 1.

How do I retain this value and show it?

Hope I have explained.

Suresh

I wouldn't use a "simple text file". Use an Xml file. Do this the same
way as I descibed in your question about "Most Recent Document".

--
Michael Lang, MCSD
See my .NET open source projects
http://sourceforge.net/projects/colcodegen/ (simple code generator)
http://sourceforge.net/projects/dbobjecter (database app code generator)
http://sourceforge.net/projects/genadonet ("generic" ADO.NET)
 
D

Dmitriy Lapshin [C# / .NET MVP]

No I don't have a sample, but just look at the Microsoft.Win32.Registry
class documentation in the MSDN - I beleive there are several samples. As
for security issues, your code will need to be granted a RegistryPermission
with appropriate access rights. This is usually not a problem for desktop
applications running on a local machine, though.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Suresh Kumaran said:
Dmitriy,

Thanks for your reply. My choice was a text file too. Just
curious to know how do you code the values to the
registry? Do you have a sample. 'Cos I have not written
any codes before to write to the registry. Also won't the
registry cause a security issue when deploying the project?

Suresh
-----Original Message-----
Suresh,

Now I see. I think registry or a simple text file would be the best choice
here. When the user closes the Form 1, read the text box value and save it
to the registry/file with the appropriate Framework classes. And upon Form 1
start-up, check whether you have previously stored value and pre-populate
the text box.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Suresh Kumaran said:
Dmitriy,

Thanks for your reply.

All right, here's what I want. My application is being
developed using VB.NET The design is this.

A. Form 1 designed for user to enter the part number. Form
1 has two buttons "Okay" and "Cancel" If the user
clicks "Okay", a textfile is validated and read for the
details of the partnumber,and the part number is passed as
aparameter to form 2.

B. Form 2 shows all other details of the partnumber such
as drawing date, approved date, description etc. These
values are placed on Form 2. Three button are availableon
form 2, "SAVE" "CANCEL" "EXIT" The user is allowed to
change any other details of the part number other than the
part number. User changes any details saves and exit the
application.

The requirement is that, if the user comes back the
application the second time around. I should be able to
show the partnumber he/she was working on in the Form 1.

How do I retain this value and show it?

Hope I have explained.

Suresh


-----Original Message-----
Suresh,

See, there is no single "best" option. I could just give
some examples on
which way fits best the nature of the application:

a) An "Options" dialog box of a desktop application.
Usually settings are
stored in the registry or in a configuration file. Please
refer to the
Microsoft.Win32.Registry class and to the
System.Configuration namespace for
more detailed information and examples.

b) A "Preferences" web page of a Web application. Web
applications most
often work with some kind of database and usually store
all information
within the database. Please refer to the System.Data
namespace documentation
for more info and examples.

c) Customer details in a desktop CRM application. Such
complex applications
also usually rely on some kind of database or structured
storage.

P.S. In fact, the question you are asking is
too "broadband". I suggest you
are facing a particular problem, and if you would
describe things you want
to achieve, I think the community could came up with more
detailed advice.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Dmitriy,

What would be the best option to do this? Do you have a
sample coding on this?

Thanks in advance,

Suresh

.

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top