View Full Version : Limit input trough inputbox


sloefmans
07-24-2007, 05:07 AM
Hi all,

I'm using an inputbox to get some input in numbers.
Allowed are : 0-9 and ","
is it possible to limit this type of input ?

Cheers , John

Guus2005
07-24-2007, 06:44 AM
In the inputbox it is not possible to restrict your input.

Create your own inputbox.

sloefmans
07-25-2007, 11:59 PM
Isn't it possible to check the input after it is in the variable ?
Ex : A= InputBox("Enter date", "some text", "1")
After this checking the contence of A is ok for me.
So i need some kind of routine which compares each character.
Any idea's ?
Thx , John

Guus2005
07-26-2007, 12:34 AM
Isn't it possible to check the input after it is in the variable ?
Yes, that is possible, but that wasn't your question.

Checking a numerical value is simple:

if IsNumeric(A) then
msgbox "Yes it is numerical"
else
msgbox "No it is not numerical"
endif


checking a string for certain characters:

Public Function CheckString(A As String) As Boolean
Dim intX As Integer, strChar As String, blnOke As Boolean

blnOke = True 'Assume succes!

For intX = 1 To Len(A)
strChar = Mid$(A, intX, 1)
Select Case strChar
Case 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ","
Case Else
blnOke = False
End Select
Next intX

If blnOke Then
MsgBox "Oke!"
Else
MsgBox "Not Oke!"
End If

CheckString = blnOke

End Function


Enjoy!

sloefmans
07-26-2007, 12:48 AM
Thx Guus , that's what i need ;-)