![]() |
|
|||||||
| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| Questions & Help Needed Post any question regarding Basic4ppc. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
I know it should be easy but I just can't figure it out.
I want to put a limit of ten chars in a textbox field ?
__________________
Endemol ![]() Waste of space ![]() O2 XDA Artemis Touch Flo 4.02 Full Cube Rom WM6.1 http://www.taximania.net |
|
||||
|
You can use my password textbox library, wich can be used as a normal textbox with a few extras....
Check the samples and tis
__________________
Paulo Gomes Porto, Portugal PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD PPC: Qtek9000, 1GB SD DLL Version Listing |
|
||||
|
I missed the obvious - this works nicely, the check for key >31 allows backspace editing of a full length textbox value.
Code:
Sub TextBox1_KeyPress (key) If StrLength( textbox1.Text) >=10 Then If Asc(key)>31 Then Textbox1.IgnoreKey End If End If End Sub Last edited by agraham : 08-27-2007 at 01:38 PM. |
|
||||
|
An improvement on my first method. I still don't understand why the insertion point moves but this code resets it. One advantage of this method is that if the user pastes in a string longer than the required length then if he tries to edit it the string is truncated which would not happen with the "ignorekey" method.
Code:
Sub TextBox1_KeyPress (key)
If StrLength( textbox1.Text) >=9 Then
If Asc(key)>31 Then
Textbox1.Text= SubString(Textbox1.Text,0,9)
Textbox1.SelectionStart = 9
End If
End If
End Sub
Code:
Sub TextBox1_KeyPress (key)
If StrLength( textbox1.Text) >=9 Then
If Asc(key)>31 Then
ss = Textbox1.SelectionStart
Textbox1.Text= SubString(Textbox1.Text,0,9)
Textbox1.SelectionStart = ss
End If
End If
End Sub
Code:
Sub TextBox1_KeyPress (key) If StrLength(textbox1.Text) >=9 AND Asc(key) > 31 Then s = textbox1.SelectionStart Textbox1.Text= SubString(Textbox1.Text,0,9) textbox1.SelectionStart = s End If End Sub Last edited by agraham : 08-27-2007 at 06:20 PM. |
|
||||
|
Many thanks, it works a treat
![]()
__________________
Endemol ![]() Waste of space ![]() O2 XDA Artemis Touch Flo 4.02 Full Cube Rom WM6.1 http://www.taximania.net |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| scrolling image with limit | europe | Questions & Help Needed | 1 | 11-07-2008 05:54 PM |
| TextBox limit number of digit to enter | mike2ppc | Questions & Help Needed | 3 | 08-12-2008 09:34 PM |
| Running programs - is there a depth limit. Also window waking | LineCutter | Questions & Help Needed | 0 | 01-28-2008 12:41 AM |
| TextBox Input Filter? | dlfallen | Questions & Help Needed | 18 | 10-10-2007 07:50 PM |
| table Dezimalseparator saveCSV 64k limit | BerndB | Questions & Help Needed | 0 | 05-02-2007 04:58 PM |