|
-
June 19th, 2006, 11:53 AM
#1
My.Setting
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If CustomerDocument = "1" Then
My.Settings.InvoiceNum = My.Settings.InvoiceNum + 1
Label8.Text = "IMON"
Label10.Text = My.Settings.InvoiceNum
My.Settings.InvoiceNum = Label10.Text
Else
My.Settings.QuoteNum = My.Settings.QuoteNum + 1
Label8.Text = "QMON"
Label10.Text = My.Settings.QuoteNum
My.Settings.QuoteNum = Label10.Text
End If
End Sub
I am using VB.Net 2005. It was suggested to me to use the My.Setting
function rather than to use SaveSetting/GetSetting which I had
originally planned to use.
The problem with the code I have pasted above is this:
InvoiceNum and QuoteNum are set to 0, when I run this code it does
complete the following process: 0 + 1 = 1 and then displays "1" in
Label10 just like I want it to do.
Now I want to save the new number displayed in Label10 as the new
setting value so that I can keep adding 1 to it everytime the Form2_Load
event happens.
I was told My.Setting would autosave but this does not seem to be the
case or I am just not doing something right. Can someone please help me
fix this?
Thanks
-
June 20th, 2006, 05:24 AM
#2
Re: My.Setting
While creating the Setting if you have selected the Scope as Applicationt hen the Setting becomes readonly. Have you tried changing the Scope of the setting in the Project Properties to User?
-
June 20th, 2006, 03:46 PM
#3
Re: My.Setting
The scope is already user.
What is the file Settings.vb for?
should I be writing what I want do in there somehow?
It says in the prewritten comments that the file generated I can use an event called SettingsSaving. Is that what I need?
'This class allows you to handle specific events on the settings class:
' The SettingChanging event is raised before a setting's value is changed.
' The PropertyChanged event is raised after a setting's value is changed.
' The SettingsLoaded event is raised after the setting values are loaded.
' The SettingsSaving event is raised before the setting values are saved.
Partial Friend NotInheritable Class MySettings
End Class
-
June 21st, 2006, 02:51 AM
#4
Re: My.Setting
You shouldn't be writing anything under MySettings class unless you are going to do something extra while Saving or changing the setting.
Do you get an error while executing/building the program? If so what does the error message say?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|