|
-
Oct 6th, 2001, 07:38 PM
#1
Thread Starter
Addicted Member
Percentage input to textbox
Sorry for the simple question, but..
Anyone point me to an example of how i can validate the contents of a textbox to only allow a percentage, ie 0 to 100.00?
All comments gratefully received unless i fall asleep *smile*
lee
-
Oct 6th, 2001, 07:41 PM
#2
Frenzied Member
Why would you want to validate a percentage to 2 decimal places.
Can;t you just make sure the contents of the test box falls between 0 and 100 instead of 100.00?
Mega.
"If at first you don't succeed, then skydiving is not for you"
-
Oct 6th, 2001, 07:41 PM
#3
PowerPoster
This any good?
VB Code:
Private Sub Text1_Validate(Cancel As Boolean)
If Val(Text1.Text) < 1 Then
MsgBox "Must be at least 1%", vbInformation
Cancel = True
ElseIf Val(Text1.Text) > 100 Then
MsgBox "Can't be more than 100%", vbInformation
Cancel = True
End If
End Sub
-
Oct 6th, 2001, 07:43 PM
#4
Try this.
VB Code:
Dim sInput As String
sInput = InputBox("Enter a percent:")
If IsNumeric(sInput) Then
If CSng(sInput) <= 100 And CSng(sInput) >= 0 Then sInput = Format$(sInput, "###.00")
End If
-
Oct 6th, 2001, 09:02 PM
#5
-
Oct 7th, 2001, 07:38 AM
#6
PowerPoster
converts a number to single
-
Oct 7th, 2001, 07:42 AM
#7
Converts numbers and strings to a single
-
Oct 7th, 2001, 07:46 AM
#8
PowerPoster
well if we're going to split hairs...converts an expression to a single data type
-
Oct 7th, 2001, 07:50 AM
#9
Well, since we at it.
Converts any string expression or numeric expression to a single.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|