Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Reference Label from TextBox

I am using a class I found here that works very well for my needs. Now
I would like to reference and change the caption of a label of the
same name (number) as the text box.

The Class:

Public WithEvents txtBox As MSForms.TextBox, CtlNum As String
Public laBl As String

Private Sub Class_Terminate()
Set txtBox = Nothing
End Sub

Private Sub txtBox_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case 46, 48 To 57
If Right(txtBox, 2) = ".5" Then KeyAscii = 0
If KeyAscii = 46 Then SendKeys ("5")
''' These are all number. No Problem
Case Else
''' Some other kind of character. Beep and cancel it.
Beep
KeyAscii = 0
End Select
SetLabel
End Sub

Private Sub txtBox_KeyDown(ByVal KeyCode As MSForms.ReturnInteger,
ByVal Shift As Integer)
If KeyCode = 8 Then txtBox.Value = ""
End Sub

Private Sub txtBox_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If Len(txtBox.Text) = 3 And Right(txtBox.Text, 2) < ".5" Then txtBox
= Null
If Len(txtBox.Text) 4 Then txtBox = Null
End Sub

'Here's where it fails.

Sub SetLabel()
'This returns the TextBox number
CtlNum = Mid(txtBox.Name, 8, Len(txtBox.Name))
laBl = "Label" & 3
MsgBox UserForm.Name.laBl.Caption
End Sub

All help will be appreciated.

Thank you.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Floating textbox/label Jock Excel Programming 6 March 10th 10 11:19 AM
Reference Label from TextBox Stephen Newman[_2_] Excel Programming 7 July 20th 08 06:27 PM
Reference Label from TextBox Stephen Newman[_2_] Excel Programming 0 July 20th 08 01:09 PM
Use a formula to populate a label from a textbox damorrison Excel Discussion (Misc queries) 5 September 4th 06 01:30 PM
textbox result to label paradise Excel Programming 2 November 15th 03 01:10 PM


All times are GMT +1. The time now is 09:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"