Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default check number on a form

I'm not quite sure of the correct terms but I want to test if a number
entered on a form is log of a power 10
ie, I want to know if the number entered is 0.001,0.01,0.1,1,10,100 etc. If
then number is not one of this series, then the user has to go back and
enter an acceptable number.
Thanks
Chris


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 227
Default check number on a form


Assuming the number on the form is entered into a text box (TextBox1) and a
command button on the form (CommandButton1) triggers the test you refer to
then perhaps....

Private Sub CommandButton1_Click()
Dim s As Double
s = Application.WorksheetFunction.Log(Val(TextBox1))
If Int(s) = s Then
MsgBox "Number OK"
Else
MsgBox "Number not OK"
End If
End Sub

(Some error checking will be required that a number has been entered into
the text box.)
--


XL2003
Regards

William



"inquirer" wrote in message
...
I'm not quite sure of the correct terms but I want to test if a number
entered on a form is log of a power 10
ie, I want to know if the number entered is 0.001,0.01,0.1,1,10,100 etc.
If then number is not one of this series, then the user has to go back and
enter an acceptable number.
Thanks
Chris



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default check number on a form

Hi,
This routine will check 10 to the power of -10 to +10. It returns
TRUE or FALSE.

Function Valid10(v) As Boolean
For i = -10 To 10 Step 1
If v = Application.Power(10, i) Then
Valid10 = True
Exit Function
End If
Next i
Valid10 = False
End Function


For example, =Valid10(A1) in cell B1 will check value of A1

or in VBA:


Sub Test()
Dim valid as Boolean
MyValue=0.0001
valid=valid10(MyValue)
End sub


HTH

"inquirer" wrote:

I'm not quite sure of the correct terms but I want to test if a number
entered on a form is log of a power 10
ie, I want to know if the number entered is 0.001,0.01,0.1,1,10,100 etc. If
then number is not one of this series, then the user has to go back and
enter an acceptable number.
Thanks
Chris



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default check number on a form

The value of these newsgroups and the people who help amateurs like me is
immeasurable.
Here was I thinking I was asking something near impossible and within a few
hours I get 2 great solutions.

Thank you
Chris

"William" wrote in message
...

Assuming the number on the form is entered into a text box (TextBox1) and
a command button on the form (CommandButton1) triggers the test you refer
to then perhaps....

Private Sub CommandButton1_Click()
Dim s As Double
s = Application.WorksheetFunction.Log(Val(TextBox1))
If Int(s) = s Then
MsgBox "Number OK"
Else
MsgBox "Number not OK"
End If
End Sub

(Some error checking will be required that a number has been entered into
the text box.)
--


XL2003
Regards

William



"inquirer" wrote in message
...
I'm not quite sure of the correct terms but I want to test if a number
entered on a form is log of a power 10
ie, I want to know if the number entered is 0.001,0.01,0.1,1,10,100 etc.
If then number is not one of this series, then the user has to go back
and enter an acceptable number.
Thanks
Chris





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
make a check form, and then have info go to a check register richie g Excel Worksheet Functions 0 May 5th 10 12:10 AM
Check Box and form Sharlene Administrative Assistant Excel Discussion (Misc queries) 0 June 3rd 09 06:47 PM
Using a template form, advance a form number everytime you open ShoDan Excel Discussion (Misc queries) 1 January 31st 08 01:34 PM
form check box sako 338 Excel Worksheet Functions 1 January 16th 07 12:33 PM
how can I make a form number change everytime the form is opened babydumplingspita Excel Worksheet Functions 1 October 10th 05 07:58 PM


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

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

About Us

"It's about Microsoft Excel"