×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Need help with code

Need help with code

Need help with code

(OP)
I am working on a project that will take information from a text box and put it into a message
on the same page. The code I am using will put the information entered on the button you
would click to display it, not in the display field.

RE: Need help with code

Create a default FORM1 with a Text1 textbox and a Command1
command button. Place the following code into your form's
code window and run. Whatever text you enter into the
textbox will display on the button when it is clicked.

Private Sub Command1_Click()
Command1.Caption = Text1.Text
End Sub

If you are wanting the button caption to be displayed the
same each time your user starts the program, it will require
you to "write" the caption information to a file, where it
can be "read" each time the program starts. This is more
involved and requires much more space than I have here to
explain it to you. You can contact me directly for this
information at jdmcjen@stc.net

HTH, Jim

RE: Need help with code

Hmmmm...

If you'd like the button caption to retain changes - perhaps you could have a look at GetSetting and SaveSetting

You could say:

Command1.text = GetSetting("MyApp","Button Text", "Command1", "Default Value")

Mike

Details Below.

(From VB Help)
GetSetting
==========
Returns a key setting value from an application's entry in the Windows registry.

Syntax

GetSetting(appname, section, key[, default])

The GetSetting function syntax has these named arguments:

Part Description
appname Required. String expression containing the name of the application or project whose key setting is requested.
section Required. String expression containing the name of the section where the key setting is found.
key Required. String expression containing the name of the key setting to return.
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 ("").
Remarks

If any of the items named in the GetSetting arguments do not exist, GetSetting returns the value of default.

SaveSetting
===========
Saves or creates an application entry in the Windows registry.

Syntax

SaveSetting appname, section, key, setting

The SaveSetting statement syntax has these named arguments:

Part Description
appname Required. String expression containing the name of the application or project to which the setting applies.
section Required. String expression containing the name of the section where the key setting is being saved.
key Required. String expression containing the name of the key setting being saved.
setting Required. Expression containing the value that key is being set to.
Remarks

An error occurs if the key setting can’t be saved for any reason.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close