|
-
Aug 25th, 2010, 03:52 PM
#1
Thread Starter
Lively Member
My.Settings problem
on close i use
Code:
My.Settings.SET20 = Form4.TextBox3.Text
My.Settings.SET21 = Form1.ComboBox2.SelectedIndex
on run i use
Code:
Form4.TextBox3.Text = My.Settings.SET20
ComboBox2.SelectedIndex = My.Settings.SET21
and then i get this error at runtime, but only the first time. Once i run it the second time its good from there on out

Help?
-
Aug 25th, 2010, 04:00 PM
#2
Re: My.Settings problem
Do you have correct data types in the "settings" properties of the project? It looks like SET20 needs to be a string and SET21 an integer. Sorry if this is obvious stuff that you have already checked. I've only just recently used My.Settings for the first time Also, I assume you have My.Settings.Save somewhere ...
-
Aug 25th, 2010, 04:11 PM
#3
Re: My.Settings problem
when you first create the settings, they have no value... so it's possible that My.Settings.SET21 is empty... and VB doesn't know how to convert that into a number... or ... the value being returned by the settings doesn't match any indexes in combobox... suggestion - default the value of SET21 to -1 in the settings screen... then that way first time it'll have a value of -1, which means nothing will be selected.
-tg
-
Aug 25th, 2010, 09:01 PM
#4
Thread Starter
Lively Member
Last edited by swingyswongy; Aug 25th, 2010 at 09:26 PM.
-
Aug 25th, 2010, 09:31 PM
#5
Thread Starter
Lively Member
Re: My.Settings problem
 Originally Posted by techgnome
when you first create the settings, they have no value... so it's possible that My.Settings.SET21 is empty... and VB doesn't know how to convert that into a number... or ... the value being returned by the settings doesn't match any indexes in combobox... suggestion - default the value of SET21 to -1 in the settings screen... then that way first time it'll have a value of -1, which means nothing will be selected.
-tg
yeah that worked! thanks!
-
Aug 25th, 2010, 09:42 PM
#6
Re: My.Settings problem
How could SET21 possibly contain an empty string unless it was type String to begin with? If the setting is to hold an Integer then it should be type Integer. You will then have to give it a numeric value. The default would be zero. ALWAYS use the correct types for EVERYTHING. If something represents a number then ALWAYS us a numeric type, etc.
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
|