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

Re: Storing Program Settings by Mike

Mike
Thu Jan 06 21:05:14 CST 2005

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.

"Vince" <sdsad@fsd.com> wrote in message
news:OVWxP$F9EHA.4072@TK2MSFTNGP10.phx.gbl...
> 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
>
>
>



Re: Storing Program Settings by Vince

Vince
Thu Jan 06 22:04:10 CST 2005

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


"Mike Harrington" <msnews@alouria.com> wrote in message
news:%231RpAXG9EHA.2192@TK2MSFTNGP14.phx.gbl...
> 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.
>
> "Vince" <sdsad@fsd.com> wrote in message
> news:OVWxP$F9EHA.4072@TK2MSFTNGP10.phx.gbl...
> > 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
> >
> >
> >
>
>



Re: Storing Program Settings by Mike

Mike
Thu Jan 06 22:38:24 CST 2005

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.

"Vince" <sdsad@fsd.com> wrote in message
news:uKCMz3G9EHA.2568@TK2MSFTNGP10.phx.gbl...
> 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
>
>
> "Mike Harrington" <msnews@alouria.com> wrote in message
> news:%231RpAXG9EHA.2192@TK2MSFTNGP14.phx.gbl...
> > 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.
> >
> > "Vince" <sdsad@fsd.com> wrote in message
> > news:OVWxP$F9EHA.4072@TK2MSFTNGP10.phx.gbl...
> > > 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
> > >
> > >
> > >
> >
> >
>
>



Re: Storing Program Settings by Vince

Vince
Thu Jan 06 22:45:52 CST 2005

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

"Mike Harrington" <msnews@alouria.com> wrote in message
news:%23hAbFLH9EHA.1392@tk2msftngp13.phx.gbl...
> 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.
>
> "Vince" <sdsad@fsd.com> wrote in message
> news:uKCMz3G9EHA.2568@TK2MSFTNGP10.phx.gbl...
> > 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
> >
> >
> > "Mike Harrington" <msnews@alouria.com> wrote in message
> > news:%231RpAXG9EHA.2192@TK2MSFTNGP14.phx.gbl...
> > > 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.
> > >
> > > "Vince" <sdsad@fsd.com> wrote in message
> > > news:OVWxP$F9EHA.4072@TK2MSFTNGP10.phx.gbl...
> > > > 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
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Re: Storing Program Settings by Ralph

Ralph
Fri Jan 07 08:34:52 CST 2005


"Vince" <sdsad@fsd.com> wrote in message
news:OSpRGPH9EHA.3076@TK2MSFTNGP15.phx.gbl...
> 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