Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Qn: Ensure Number is valid for a circle??

Hello Everyone,

I am trying to put in a error trap with a MsgBox to check and see if a
number that is input into a TextBox is NOT a valid number. The TextBox
input is for a Wind Direction such as 040 degrees, OR 180 degrees. Now,
since the direction of the wind is only valid for 360 degrees in a circle,
is there a way to ensure the number they input meets the criteria for a
degree. Example: If they put in the number 36, my wind formula will not
calculate the correct wind correction angle from the runway. The wind
direction MUST be 360 to calculate properly. Can I do a error routine to
ensure that??
Thanks in Advance... mv

PS: Tom... your my man!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Ensure Number is valid for a circle??

Unless there is some other information you can use in conjunction with this
value, the best you could do is check that the number is between 0 and 359
inclusive or 1 and 360 inclusive. If your example represents entering 36
when 360 was intended, there is no way to determine that 360 was intended
rather than 36 degrees. If you only accept numbers divisible by 5 or 10,
then you could use the MOD operator to check that. (but 30 vice 300).
Perhaps you could add an additional entry such as N, NW, SE etc and check
your numbers in conjunction with that.

In any event, your code would go in the exit event if the textbox is on a
userform.

--
Regards,
Tom Ogilvy

"Michael Vaughan" wrote in message
...
Hello Everyone,

I am trying to put in a error trap with a MsgBox to check and see if a
number that is input into a TextBox is NOT a valid number. The TextBox
input is for a Wind Direction such as 040 degrees, OR 180 degrees. Now,
since the direction of the wind is only valid for 360 degrees in a circle,
is there a way to ensure the number they input meets the criteria for a
degree. Example: If they put in the number 36, my wind formula will not
calculate the correct wind correction angle from the runway. The wind
direction MUST be 360 to calculate properly. Can I do a error routine to
ensure that??
Thanks in Advance... mv

PS: Tom... your my man!




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Ensure Number is valid for a circle??

Hi Michael

You can use the Exit event of the textbox to test the input.


Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not IsNumeric(TextBox1) Or Len(TextBox1) 3 Then Cancel = True
Me.TextBox1.Text = Format(TextBox1, "000")
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Michael Vaughan" wrote in message ...
Hello Everyone,

I am trying to put in a error trap with a MsgBox to check and see if a
number that is input into a TextBox is NOT a valid number. The TextBox
input is for a Wind Direction such as 040 degrees, OR 180 degrees. Now,
since the direction of the wind is only valid for 360 degrees in a circle,
is there a way to ensure the number they input meets the criteria for a
degree. Example: If they put in the number 36, my wind formula will not
calculate the correct wind correction angle from the runway. The wind
direction MUST be 360 to calculate properly. Can I do a error routine to
ensure that??
Thanks in Advance... mv

PS: Tom... your my man!




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Ensure Number is valid for a circle??

Michael,
Instead of poping up an Input box, why not show them a userform with a
compass-like graphic and arrow that they can drag around to the correct
direction. You couls even only allow certain increments, 15o say.
No validation required as the must give you a valid response and kudos for
style.

NickHK

"Michael Vaughan" wrote in message
...
Hello Everyone,

I am trying to put in a error trap with a MsgBox to check and see if a
number that is input into a TextBox is NOT a valid number. The TextBox
input is for a Wind Direction such as 040 degrees, OR 180 degrees. Now,
since the direction of the wind is only valid for 360 degrees in a circle,
is there a way to ensure the number they input meets the criteria for a
degree. Example: If they put in the number 36, my wind formula will not
calculate the correct wind correction angle from the runway. The wind
direction MUST be 360 to calculate properly. Can I do a error routine to
ensure that??
Thanks in Advance... mv

PS: Tom... your my man!




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
how do i circle a number? Teresa Excel Discussion (Misc queries) 2 April 3rd 23 07:31 PM
How do I make circle within circle graphs in Excel 2003? Lance Charts and Charting in Excel 2 December 5th 06 01:59 AM
How do I circle a number in excel Dan Butler Excel Worksheet Functions 1 April 4th 06 10:16 PM
In Excel, how can I type a number with a circle around it? farundrpar Excel Worksheet Functions 1 January 27th 06 01:15 AM
How circle an individual number in a cell? Chet Excel Worksheet Functions 3 January 26th 06 11:39 PM


All times are GMT +1. The time now is 05:01 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"