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 Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inputbox - can you set maximum length? 1

Status
Not open for further replies.

chequi

IS-IT--Management
Apr 24, 2000
24
PR
Hello:

I need to know if you can set a maximum length for an inputbox in VB6 ?

Thanks.

Chequi.
 
strResponse = InputBox("ENTER NEW SCHEDULE DATE (YYYYMMDD)"

if len(strResponse)> 10 then
give error
end if
 
Yes. But I am trying to do is to set a maximum length as you do with a text box; so that the user can not enter in excess of those characters.

Chequi.
 
Chequi,

To my knowledge they is no "Max Length" setting for a inputbox. The example I give you will limit the number of characters entered.
 
Sure it can be done. Just do a keyword search in her for one of the solutions that allow you to intercept the creation of the Input box (two types; Hypetia's favoured timer technique, and my favoured CBT Hook technique). Either way you get the handle of the window being created, and can send it a message. In this case you want to send the EM_LIMITTEXT message, e.g.

SendMessage hwndEditControl, EM_LIMITTEXT, 5, 0

would limit input to a maximum of 5 characters.

Voila!
 
Thanks Strongm,

I did not know that...

Have a star!
 
Hello:
I am glad to know there is a solution. Thanks to both of you WZUP and Strongm.

But it seems I need more help. Strongm says:

" Either way you get the handle of the window being created, and can send it a message. In this case you want to send the EM_LIMITTEXT message, e.g.

SendMessage hwndEditControl, EM_LIMITTEXT, 5, 0 "

What kind of declarations do I need? Could show me the exact coding?

I will appreciate your help very much.

Chequi.


 
What level of VB knowledge are we pitching to? I ask because:

a) almost all the coding you need is already available in fulldetail in this forum. You just need to do a search

b) having been given the exact Window message you need to deal with (which differs from the message in the examples in this forum which tend to dwell on masking password characters), you should be able to get the necessary help info from MSDN, and the correct VB declarations from the API Text Viewer included with VB
 
chequi,

It is better to replace input box with a regular form. When you put a text box on that form then you will be able limit it length using it's property.

vladk
 
Strongm:

I am not a big leaguer but I can find my way to solve my problem. Thank you anyway.

Chequi.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top