default values

default values

Anonymous
Not applicable
612 Views
6 Replies
Message 1 of 7

default values

Anonymous
Not applicable
Hello,

I would like to have a 'default' button on a form that saves the value of a text box in vba, to its value property. So that the next time the macro is loaded and run the 'default' value is loaded. I know it is possible to load and unload references at runtime, but i'm not sure about changing form and control properties. This would save having to deal with writing and reading from another file which would also have to be maintained.

thanks
0 Likes
613 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
You type 'default' value into Text or Value
property of TextBox in Property Window while you design your form. By doing
this, whenever your form is loaded, the 'default value' is set in the text
box.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hello,

I would like to have a 'default' button on a form that saves the value of a
text box in vba, to its value property. So that the next time the macro is
loaded and run the 'default' value is loaded. I know it is possible to load
and unload references at runtime, but i'm not sure about changing form and
control properties. This would save having to deal with writing and reading
from another file which would also have to be maintained.

thanks

0 Likes
Message 3 of 7

Anonymous
Not applicable
ok, now what i mean is... How do you change that Value property of the TextBox at runtime. I want to have a 'set as default' button that hard codes the new 'default' values into the vba code.

thanks
lorier
0 Likes
Message 4 of 7

Anonymous
Not applicable
lorier had this to say:

> ok, now what i mean is... How do you change that Value property of
> the TextBox at runtime. I want to have a 'set as default' button
> that hard codes the new 'default' values into the vba code.
> thanks
> lorier

Look into the SaveSetting and GetSetting functions to store your
information in the registry.

--
http://www.acadx.com
0 Likes
Message 5 of 7

Anonymous
Not applicable
Store the value in the Registry... That's what it's
for...

 

Public Sub Userform1_Initialize ()

    TextBox 1 = Getsetting
("MyProgram", "MySettings", "MyKey", "MyDefaultValue")

End Sub

 

Public Sub Userform1_Deactivate()

    Savesetting (""MyProgram",
"MySettings", "MyKey", Me.TextBox1.value)

End Sub


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
ok,
now what i mean is... How do you change that Value property of the TextBox at
runtime. I want to have a 'set as default' button that hard codes the new
'default' values into the vba code.

thanks
lorier

0 Likes
Message 6 of 7

Ed__Jobe
Mentor
Mentor
Another option is to save the value to a global variable in your module. The disadvantage to that is that the value will be cleared each time you unload the module or close acad. Sometimes its enough to save the variable for the current session only. -Ed

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 7 of 7

Anonymous
Not applicable
Thanks Aaron! Didn't know it was that simple.
0 Likes