User Form Text & label button

User Form Text & label button

Anonymous
Not applicable
217 Views
1 Reply
Message 1 of 2

User Form Text & label button

Anonymous
Not applicable
I would like to create a form with a text button and a label button.

The Value of the Label button equal the value of the text button / 456
(eg.).

How do I set (what code?) my label button to be updated after i enter a
value in the text button?
kh
0 Likes
218 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Hi Schuyl,
try this:
get a user form with label1 and textbox1 and commandbutton1

if you want it to change contiunuously:
(the instant gratification method:)

Option Explicit

Private Sub TextBox1_Change()
'you'd have to restrict entry to numeric or handle error here

On Error Resume Next
Label1.Caption = TextBox1.Value / 456
If Err then
'the text wasn't numeric most likely so do something....
MsgBox "Make that Numeric Please"
End If
End Sub

or if you wanted it to change after you'd entered something then add a
command button and:

Private Sub CommandButton1_Click()
On Error Resume Next
Label1.Caption = TextBox1.Value / 456
If Err Then
'the text wasn't numeric most likely so do something....
MsgBox "Make that Numeric Please"
'you'd have to restrict entry to numeric or handle error here
End If
End Sub

of course that assumes you have a form with a label control, a textbox
control and a command button named as above(default names)
that should give you a start
Mark

Schuyl wrote in message
news:934AB58CE5E1DAEA73C7DE0373A79AD0@in.WebX.maYIadrTaRb...

> I would like to create a form with a text button and a label button.
>
0 Likes