Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default SpinButton/TextBox - Large Number

I have a large number of SpinButton/TextBox combinations on a userform
(~50). I'm trying to figure out if there's a better way than writing
this type of code 50 times:

Private Sub SpinButton_MeltPower1_Change()
TextBox_MeltPower1.Value = SpinButton_MeltPower1.Value
End Sub
Private Sub TextBox_MeltPower1_Change()
SpinButton_MeltPower1.Value = TextBox_MeltPower1.Value
End Sub

I also need to figure out how to trap if they write text into the text
box (rather than a number), pop up an error, and then change the value
of the text box back to the original value. Right now, the above code
crashes out (not suprisingly), when it tries to set the value of the
the spinbutton to a text string.

Any help is appreciated,
John

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default SpinButton/TextBox - Large Number

John, first check out this code from J-Walk:
http://j-walk.com/ss/excel/tips/tip44.htm
Let me know if you need help implementing that. Second, when I attach a
spinner to a textbox I usually disable the textbox so it must be
changed via the spinner, this works very well to keep stupid users from
entering text. If you wish to allow the user to enter a number
manually, use the TextBox_Enter event to trap the value when the user
clicks in the box and store the value to a global variable, then when
they exit the checkbox do your error checking to verify that it is a
number, if not then reset back to the global variable. Once again reply
back if you need code samples.

Charles Chickering
John Fuller wrote:
I have a large number of SpinButton/TextBox combinations on a userform
(~50). I'm trying to figure out if there's a better way than writing
this type of code 50 times:

Private Sub SpinButton_MeltPower1_Change()
TextBox_MeltPower1.Value = SpinButton_MeltPower1.Value
End Sub
Private Sub TextBox_MeltPower1_Change()
SpinButton_MeltPower1.Value = TextBox_MeltPower1.Value
End Sub

I also need to figure out how to trap if they write text into the text
box (rather than a number), pop up an error, and then change the value
of the text box back to the original value. Right now, the above code
crashes out (not suprisingly), when it tries to set the value of the
the spinbutton to a text string.

Any help is appreciated,
John


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default SpinButton/TextBox - Large Number

you can use this **technique** documented at John Walkenbach's site:

http://www.j-walk.com/ss/excel/tips/tip44.htm

You could use the change event of the textbox to reject non numeric input.
It could check the spinbutton to see what value to restore.

--
Regards,
Tom Ogilvy



"John Fuller" wrote:

I have a large number of SpinButton/TextBox combinations on a userform
(~50). I'm trying to figure out if there's a better way than writing
this type of code 50 times:

Private Sub SpinButton_MeltPower1_Change()
TextBox_MeltPower1.Value = SpinButton_MeltPower1.Value
End Sub
Private Sub TextBox_MeltPower1_Change()
SpinButton_MeltPower1.Value = TextBox_MeltPower1.Value
End Sub

I also need to figure out how to trap if they write text into the text
box (rather than a number), pop up an error, and then change the value
of the text box back to the original value. Right now, the above code
crashes out (not suprisingly), when it tries to set the value of the
the spinbutton to a text string.

Any help is appreciated,
John


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default SpinButton/TextBox - Large Number

Thanks. That should do the trick.


Tom Ogilvy wrote:
you can use this **technique** documented at John Walkenbach's site:

http://www.j-walk.com/ss/excel/tips/tip44.htm

You could use the change event of the textbox to reject non numeric input.
It could check the spinbutton to see what value to restore.

--
Regards,
Tom Ogilvy



"John Fuller" wrote:

I have a large number of SpinButton/TextBox combinations on a userform
(~50). I'm trying to figure out if there's a better way than writing
this type of code 50 times:

Private Sub SpinButton_MeltPower1_Change()
TextBox_MeltPower1.Value = SpinButton_MeltPower1.Value
End Sub
Private Sub TextBox_MeltPower1_Change()
SpinButton_MeltPower1.Value = TextBox_MeltPower1.Value
End Sub

I also need to figure out how to trap if they write text into the text
box (rather than a number), pop up an error, and then change the value
of the text box back to the original value. Right now, the above code
crashes out (not suprisingly), when it tries to set the value of the
the spinbutton to a text string.

Any help is appreciated,
John



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
Set Textbox value = large(ARRAY,k) BlueWolverine Charts and Charting in Excel 1 July 29th 09 05:03 PM
Easy Reading - large number minus small number MUTTMIND New Users to Excel 5 February 5th 09 10:08 AM
Textbox disappears in large chart-Excel bug? [email protected] Excel Discussion (Misc queries) 2 November 1st 05 03:13 PM
Hard Return in large textbox Todd Huttenstine Excel Programming 2 July 12th 04 10:02 PM
Spinbutton Linked to Textbox David Reid[_2_] Excel Programming 2 August 19th 03 04:25 PM


All times are GMT +1. The time now is 04:29 PM.

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"