Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input box validation 1

Status
Not open for further replies.

Crazyf

Programmer
Jun 15, 2007
29
0
0
GR
Hi everybody,
I want to validate the textbox of inputbox in a program in vb6. Is it possible to happen?
The kind of validation i need to is to accept a number from 1 up to 100 or double numbers in this space (1 to 100) ex 1.5 16.6 type and no other ascii character.
Any help will be much appreciated.

Thank you
in advanced
 
So, what do you have so far?

Show me your code for your inputbox that you have now ....

Have fun.

---- Andy
 
>I want to validate the textbox of inputbox in a program in vb6. Is it possible to happen?

Not as you are typing it in. Only after the fact. However, if you want to do this all you really have to do is create a form that looks like the inputbox. Then you can do whatever you like with it.

HTH

Bob
 
Andy:

percent = InputBox("Give a number from 1 to 100","Persentage")

PercentNew=val(percent)/100

As I told you before, a want to handle the textbox of inputbox. I don't know how to explain it better. The what i want is the user type only a number between 1 and 100 also i want the user to have the possibility to type a long type number between 1 and 100 for examle 10.5, 1.4, 76,88 whatever. Although, i want if he types something else for example an alphabetic character, or punctuations sticks, if it is possible to refer with code in the textbox of the input box in the keypress event, the keyascii=0. Every time the user presses an alphabetic character or a punctuation stick the keyascii=0. My problem is that i don't know if it is feasible to do this, i don't know if a have the possibility to handle the textbox that appears in the input box when the program runs and i don't know too the manner to manage this.
I hope you understood the what i want i do. Any help will be much appreciated.

Although, Bob, you have a great idea, if i don't find any solution to handle the textbox of inputbox i will follow your instructions.

Thanks you both.
 
Crazyf
Ntest = InputBox("Please enter a number between 1 and 100")
If Ntest >= 1 OR Ntest <= 100 then
DO SOMETHING HERE
Else
MsgBox "Please enter a number between 1 and 100"

Regards
David
 
Hey Guys,

I'm trying to validate a data from Inputbox.
But it gets little complicated, because I dont know first of all how many characters data going to be , and it is not really important for the project.
WHat I need to validate is the first character of the data and the last character, for example

InputBox = " Hello World! "
Validate this box that if InputBox first character is "H" and last character is "!" then do something

else
please type correct format


Anybody can help me with this coding?
 
The input box does not have any events associated with it that you can get to in VB. You'll have to use a textbox on a form to do what you want.

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
Try this one out.

Code:
dim blnTryAgain as Boolean, lngPercent as long

blnTryAgain = True

While blnTryAgain
 percent = InputBox("Give a number from 1 to 100","Persentage")

lngPercent = clng(percent)

If lngPerrcent >1 and lngPercent > 100 then
 PercentNew=lngpercent/100
 blnTryAgain=False
end if
Wend

HTH

Note: Its been a while since i coded in VB; please check the functions (clng etc) do exist
Engi
 
If lngPerrcent >1 and lngPercent > 100 then [glasses]

[gray]Experience is something you don't get until just after you need it.[/gray]
 
oh... accept my apologies.

should have been

Code:
If lngPerrcent >=1 and lngPercent <= 100 then

Once again I apologize to this forum.
 
<do I get to understand the meaning of that sigh, Bob!!!

Probably not. I'm the enigmatic sort. :)

Seriously, not a reaction to your post directly. I just felt that the OP is being misled by some of the responses. It seemed to me that the OP was asking for the ability to validate keystrokes in the input box as the user made them, not to evaluate the entire string after the fact. As we all know, that can't be done with the InputBox function, so all of the suggestions given were not useful to the OP given that he wants what he wants. Rather, they were of the character of red herrings for him to chase.

So, Crazyf: unless I completely misunderstand your posts, no, you can NOT do what you want using an InputBox. You WILL have to make a form to do that.

Ok? :)

HTH

Bob
 
Thank you everybody reply me.
I can see Bob that you understood clearly the what i wanted to do, and i am glad gave me a clearly response for my problem.
Although, i supposed that it couldn't be done, by the other's responses and i already created a new form with a textbox validated keystrokes from there with code and i did everything i want and works perfectly. ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top