Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with code

Status
Not open for further replies.

tracy

MIS
Aug 10, 1999
1
0
0
US
I am working on a project that will take information from a text box and put it into a message<br>
on the same page. The code I am using will put the information entered on the button you <br>
would click to display it, not in the display field. <br>

 
Create a default FORM1 with a Text1 textbox and a Command1<br>
command button. Place the following code into your form's<br>
code window and run. Whatever text you enter into the<br>
textbox will display on the button when it is clicked.<br>
<br>
Private Sub Command1_Click()<br>
Command1.Caption = Text1.Text<br>
End Sub<br>
<br>
If you are wanting the button caption to be displayed the<br>
same each time your user starts the program, it will require<br>
you to "write" the caption information to a file, where it<br>
can be "read" each time the program starts. This is more<br>
involved and requires much more space than I have here to<br>
explain it to you. You can contact me directly for this<br>
information at jdmcjen@stc.net<br>
<br>
HTH, Jim
 
Hmmmm...<br>
<br>
If you'd like the button caption to retain changes - perhaps you could have a look at GetSetting and SaveSetting<br>
<br>
You could say:<br>
<br>
Command1.text = GetSetting("MyApp","Button Text", "Command1", "Default Value")<br>
<br>
Mike<br>
<br>
Details Below.<br>
<br>
(From VB Help)<br>
GetSetting<br>
==========<br>
Returns a key setting value from an application's entry in the Windows registry.<br>
<br>
Syntax <br>
<br>
GetSetting(appname, section, key[, default])<br>
<br>
The GetSetting function syntax has these named arguments:<br>
<br>
Part Description<br>
appname Required. String expression containing the name of the application or project whose key setting is requested.<br>
section Required. String expression containing the name of the section where the key setting is found.<br>
key Required. String expression containing the name of the key setting to return.<br>
default Optional. Expression containing the value to return if no value is set in the key setting. If omitted, default is assumed to be a zero-length string ("").<br>
Remarks<br>
<br>
If any of the items named in the GetSetting arguments do not exist, GetSetting returns the value of default.<br>
<br>
SaveSetting<br>
===========<br>
Saves or creates an application entry in the Windows registry.<br>
<br>
Syntax <br>
<br>
SaveSetting appname, section, key, setting<br>
<br>
The SaveSetting statement syntax has these named arguments:<br>
<br>
Part Description<br>
appname Required. String expression containing the name of the application or project to which the setting applies.<br>
section Required. String expression containing the name of the section where the key setting is being saved.<br>
key Required. String expression containing the name of the key setting being saved.<br>
setting Required. Expression containing the value that key is being set to.<br>
Remarks<br>
<br>
An error occurs if the key setting can’t be saved for any reason.<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top