Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Syntax for Logical Operators to Limit Input?


Good Morning,
I am creating a data entry form and have followed the tutorials written
by Peter Aitken in MSDN . He shows how to limit entry to numerical
values and that is very clear. I am trying to allow the user to enter
a percent such as 21.2%.

I just can't seem to find the right syntax . I can limit to the
decimal point or to the percent sign with a single statement. Or I can
limit to the numerical range of 1 through 9, but I can't seem to do all
three with one statement.

Here is the last statement I tried:

Private Sub txtSolidsRaw_KeyPress(ByVal KeyAscii _
As MSForms.ReturnInteger)

If KeyAscii < 36 Or KeyAscii < 46 Or KeyAscii < 48 _
Or KeyAscii < 49 Or KeyAscii < 50 Or KeyAscii < 51 _
Or KeyAscii < 52 Or KeyAscii < 53 Or KeyAscii < 54 _
Or KeyAscii < 55 Or KeyAscii < 56 Or KeyAscii < 57 Then

KeyAscii = 0

End If

End Sub


--
DCSwearingen


------------------------------------------------------------------------
DCSwearingen's Profile: http://www.excelforum.com/member.php...o&userid=21506
View this thread: http://www.excelforum.com/showthread...hreadid=499375

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Syntax for Logical Operators to Limit Input?

% is 37

? asc("%")
37

Private Sub txtSolidsRaw_KeyPress(ByVal KeyAscii _
As MSForms.ReturnInteger)

If not ((KeyAscii 48 And KeyAscii <= 57) or KeyAscii = 46 _
or KeyAscii = 37) Then

KeyAscii = 0

End If

end if

--
Regards,
Tom Ogilvy

"DCSwearingen"
wrote in message
news:DCSwearingen.21dfrm_1136816702.3105@excelforu m-nospam.com...

Good Morning,
I am creating a data entry form and have followed the tutorials written
by Peter Aitken in MSDN . He shows how to limit entry to numerical
values and that is very clear. I am trying to allow the user to enter
a percent such as 21.2%.

I just can't seem to find the right syntax . I can limit to the
decimal point or to the percent sign with a single statement. Or I can
limit to the numerical range of 1 through 9, but I can't seem to do all
three with one statement.

Here is the last statement I tried:

Private Sub txtSolidsRaw_KeyPress(ByVal KeyAscii _
As MSForms.ReturnInteger)

If KeyAscii < 36 Or KeyAscii < 46 Or KeyAscii < 48 _
Or KeyAscii < 49 Or KeyAscii < 50 Or KeyAscii < 51 _
Or KeyAscii < 52 Or KeyAscii < 53 Or KeyAscii < 54 _
Or KeyAscii < 55 Or KeyAscii < 56 Or KeyAscii < 57 Then

KeyAscii = 0

End If

End Sub


--
DCSwearingen


------------------------------------------------------------------------
DCSwearingen's Profile:

http://www.excelforum.com/member.php...o&userid=21506
View this thread: http://www.excelforum.com/showthread...hreadid=499375



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Syntax for Logical Operators to Limit Input?


Thank You!!

I had a typo in my earlier message. I did have 37 for the percen
sign in my code. I needed the parenthesis to combine the operations.
I'll have to remember that in the future!!

Again, thanks to all who post answers on this forum. I read a lot o
the answers, even if I have not run across the issue

--
DCSwearinge

-----------------------------------------------------------------------
DCSwearingen's Profile: http://www.excelforum.com/member.php...fo&userid=2150
View this thread: http://www.excelforum.com/showthread.php?threadid=49937

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
Logical operators not working with text??? Slinky[_2_] Excel Worksheet Functions 3 May 27th 09 09:03 PM
Limit on logical function AJ[_4_] Excel Discussion (Misc queries) 4 October 29th 08 12:23 AM
IF STATEMENT - HOW TO STRUCTURE THE LOGICAL OPERATORS SSJ New Users to Excel 8 April 9th 07 11:15 AM
Can logical operators be used within Conditional Formatting? Rumpa Biswas Excel Discussion (Misc queries) 6 January 2nd 06 10:58 AM
How to input a range in a logical test? Help Me Rhonda TOA[_2_] Excel Programming 1 August 21st 04 09:18 PM


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