Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2005

Tip: Looking for answers? Try searching our database.

Storing Program Settings

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Vince - 07 Jan 2005 02:22 GMT
Hello,

I have around 30 (at most) text boxes and combo boxes that have settings
which need to be stored and restored when the program starts. (This is a VBA
program but I think, it also applies to VB). In the future, many more
settings could be added and they would also have to be saved and loaded
(like a template a program uses for different conditions). I am not sure
about the best way to go about this that could save coding in the long run.
I wanted to write a text file like:

Condition1;Value1;Value2;Value3
Condition2;Value1;Value2;Value3
Condition3;Value1;Value2;Value3

and when loading this file, to load (say) the first three textboxes with
their corresponding values, I would split each line and check the condition
and populate the textboxes / comboboxes. Is this the best way to do this?

Thank you for your time / responses.

Vince
Mike Harrington - 07 Jan 2005 03:05 GMT
Depending on your needs a simple flat text file that is CSV or TAB
deliminated should work nicely, or if you don't want to bother with file IO
(something that might be less than ideal if it's a macro) you could always
save the information to the registry.  Optionally you could always save it
in INI file format or XML format if you need it to be a bit more robust.
Using a flat text file like you mentioned would probably be the best/easiest
choice though.

> Hello,
>
[quoted text clipped - 17 lines]
>
> Vince
Vince - 07 Jan 2005 04:04 GMT
Thanks Mike.

INI seems much easier. I just looked it up and found the following. Is there
such a thing defined for XML as well? A function that would return the
immediate root element and so forth? Would be cool to have an XML because I
could write a DTD to validate it. Also, I hear XML could be made secure. I
am not sure how though.
Public Declare Function GetPrivateProfileString Lib "kernel32" _

Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal _

lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As _

String, ByVal nSize As Long, ByVal lpFileName As String) As Long

Dim LReturn As Long

Dim Suse1 As String

Dim sRetBuf As String

Dim iLenBuf As Integer

sRetBuf$ = String$(256, 0)

iLenBuf% = Len(sRetBuf$)

LReturn = GetPrivateProfileString("Settings", "dude", "", sRetBuf$,
iLenBuf%, "c:\replicator\Settings.ini")

Suse1 = Left$(sRetBuf, LReturn)

msgbox(suse1) ' Prints Ain't it a lovely day

[Settings]

dude=Ain't it a lovely day

> Depending on your needs a simple flat text file that is CSV or TAB
> deliminated should work nicely, or if you don't want to bother with file IO
[quoted text clipped - 28 lines]
> >
> > Vince
Mike Harrington - 07 Jan 2005 04:38 GMT
For XML you would have to use one of the MSXML libraries which would have to
be installed on the client's computer.  Almost everyone has at least one
version running, but may not necessarily have the latest and greatest
(depends on the OS and what software they have installed).  Generally I have
found use the least possible version (Windows 2000 and above comes with
MSXML 2.0).  They're not as easy to work with as INI files, but once you get
used to it, it can be very powerful.

> Thanks Mike.
>
[quoted text clipped - 69 lines]
> > >
> > > Vince
Vince - 07 Jan 2005 04:45 GMT
Thanks for the info Mike. I'll stick with INI for now and read up on the XML
library for a future project. From the trends I observe, I think everything
in the future will be based on XML. I've also heard that the new version of
Windows (think it's 2005) uses XML libraries instead of the usual registry.

Vince

> For XML you would have to use one of the MSXML libraries which would have to
> be installed on the client's computer.  Almost everyone has at least one
[quoted text clipped - 87 lines]
> > > >
> > > > Vince
Ralph - 07 Jan 2005 14:34 GMT
> Thanks for the info Mike. I'll stick with INI for now and read up on the XML
> library for a future project. From the trends I observe, I think everything
> in the future will be based on XML. I've also heard that the new version of
> Windows (think it's 2005) uses XML libraries instead of the usual registry.
>
> Vince

I have also heard that XML is going to replace SQLServer, Oracle and DB2. It
is going to be the primary media for all HiDef Wireless services, and will
eventually extend our lifetimes beyond 100+ years.

But then I don't necessary believe everything I hear.

-ralph

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.