Save Option Button

Save Option Button

Jonathan3891
Advisor Advisor
1,304 Views
1 Reply
Message 1 of 2

Save Option Button

Jonathan3891
Advisor
Advisor

Whats up everyone?

 

I need to be able to save a selected option button when the userform and/or AutoCAD is closed and then recall the selected option button when the userform is initialized.

 

I have this feature working for drop down boxes but for the life of me cant figure out how do do the same with a option button.

 

For drop down boxes I'm currently using a Save Macro that looks like this:

SaveSetting "MyMacro", "Settings", _
"Bsize_Pltr", Me.Bsize_Pltr.Text

And  Load Macro that looks like this:

Me.Bsize_Pltr.Text = GetSetting _
("MyMacro", "Settings", "Bsize_Pltr", "")

I'm thinking I can use a frame tag to save the option button value but how do I recall this on the userform initialization?

 

I appreciate any help on this.

 

 


Jonathan Norton
Blog | Linkedin
0 Likes
Accepted solutions (1)
1,305 Views
1 Reply
Reply (1)
Message 2 of 2

norman.yuan
Mentor
Mentor
Accepted solution

My unserstanding is that you want to save a OtionButton(RadioButton)'s value in VBA settings and retrieve it when next time when the form is shown and use the retrieved value to set the OptionButton's value.

 

I also understand that the reason you stuck is that OptionButton's value is Boolean type, while the value for SaveSettings to save is String type. You can easily use CBool()/Cstr() to convert OptionButton's value between Boolean and String value:

 

SaveSettings "AppName", "SectionName", "KeyName", CStr(OptionButton1.Value)

 

Dim optButtonValueAs String

optButtonValue =GetSettings("ApppName","SectionName", "KeyName")

OptionButton1.Value=Iif(Len(optButtonValue)=0, False, CBool(optButtonValue)

 

Note, when retrieve setting value, there could be no value available (default to an empty string), because your program has not call SaveSettings once. So, you need to expect that and do things accordingly, as showed here.

Norman Yuan

Drive CAD With Code

EESignature