my.settings help

T

thomasp

Using VB2005

I have a form that allows the user to set a time offset for imported
records. I am trying to save this value with My.setting so that it is
loaded each time the program is used. I was doing this with an .ini file
but thought that I should try to use this new feature. I set it up as a
application setting but soon found out this is readonly and cannot be set
while the program is running, so I changed it to a user setting. Problem
is, it will work only part of the time. The user may open the program twice
and all is fine, next time the program is open the setting will be gone.

Any suggestions?

Thanks,

Thomas

Private Sub ComboBox3_Validating(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles ComboBox3.Validating

cmdOK.Enabled = True

If IsNumeric(ComboBox3.Text) AndAlso (Val(ComboBox3.Text) >= -12
AndAlso Val(ComboBox3.Text) <= 12) Then
ErrorProvider1.SetError(Me.ComboBox3, "")
strUTAMSOffset = Trim(ComboBox3.Text.ToString)
My.Settings.UTAMSOffset = strUTAMSOffset
My.Settings.Save()
Else
ErrorProvider1.SetIconAlignment(Me.ComboBox3,
ErrorIconAlignment.MiddleLeft)
ErrorProvider1.SetError(Me.ComboBox3, "Entry must be a number
between -12 and 12.")
ComboBox3.Focus()
cmdOK.Enabled = False
End If

End Sub
 
G

Guest

If the Application Settings are readonly, what is the value in using them...I
would think that you could do just as well and as easy to hard code settings
as constants in an application. Am I missing something?
 
G

Guest

y not just go old school and use an INI file that can edited even during the
program? thats what i use for my programs and it works great
 
T

thomasp

I was using an .ini file and may go back to it. I just thought this was
suppose to be the new and better way. Everything I read says .ini file are
a thing of the past, but nobody gives a good replacement for them.

Thomas
 
C

Chad Z. Hower aka Kudzu

(e-mail address removed) wrote in
I was using an .ini file and may go back to it. I just thought this
was suppose to be the new and better way. Everything I read says .ini
file are a thing of the past, but nobody gives a good replacement for
them.

Here is a good replacement as well as a discussion of the INI, registry etc and why not to use them:
http://www.codeproject.com/dotnet/XMLSettingsFile.asp


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Develop ASP.NET applications easier and in less time:
http://www.atozed.com/IntraWeb/
 

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