[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

How to disable the delete-button (keyascii=46) in a textbox in vb6

catharinus

9/22/2011 9:16:00 AM

Hello my friends
I have a texbox in which I want to insert, delete or update text.
I want to disable the keyascii = 46 (the delete-button)

I use the subrouitine Text1_keypress (keyascii as integer)
It contains, among more things,. the following code:

select case keyascii

'case 9, 13, 27
keyascii = 0
case 8
code for the backspace key
else
text1.text=text1.text & chr(keyascii)
end case

But the keyascii = 46 does not work in this.
Any idea??

Thanks
Catharinus
5 Answers

Dee Earley

9/22/2011 9:27:00 AM

0

On 22/09/2011 10:15, Catharinus wrote:
> Hello my friends
> I have a texbox in which I want to insert, delete or update text.
> I want to disable the keyascii = 46 (the delete-button)
>
> I use the subrouitine Text1_keypress (keyascii as integer)
> It contains, among more things,. the following code:
>
> select case keyascii
>
> 'case 9, 13, 27
> keyascii = 0
> case 8
> code for the backspace key
> else
> text1.text=text1.text& chr(keyascii)
> end case
>
> But the keyascii = 46 does not work in this.
> Any idea??

Ignore your sample code being invalid, you should be checking for the
control character keys in the KeyDown event and check for the
appropriate KeyCode.
If it's one you want to block, just set it to 0 and leave the rest to
the control.

--
Dee Earley (dee.earley@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk...

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)

catharinus

9/22/2011 9:38:00 AM

0

On 22 sep, 11:27, Deanna Earley <dee.ear...@icode.co.uk> wrote:
> On 22/09/2011 10:15, Catharinus wrote:
>
>
>
>
>
> > Hello my friends
> > I have a texbox in which I want to insert, delete or update text.
> > I want to disable the keyascii = 46 (the delete-button)
>
> > I use the subrouitine Text1_keypress (keyascii as integer)
> > It contains, among more things,. the following code:
>
> > select case keyascii
>
> > 'case 9, 13, 27
> >      keyascii = 0
> > case 8
> >     code for the backspace key
> > else
> >      text1.text=text1.text&  chr(keyascii)
> > end case
>
> > But the keyascii = 46 does not work in this.
> > Any idea??
>
> Ignore your sample code being invalid, you should be checking for the
> control character keys in the KeyDown event and check for the
> appropriate KeyCode.
> If it's one you want to block, just set it to 0 and leave the rest to
> the control.
>
> --
> Dee Earley (dee.ear...@icode.co.uk)
> i-Catcher Development Teamhttp://www.icode.co.uk...
>
> iCode Systems
>
> (Replies direct to my email address will be ignored.
> Please reply to the group.)- Tekst uit oorspronkelijk bericht niet weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -

Thanks

Doing so causes the deletion of part of the text in the textbox
Any idea?

Catharinus

Dee Earley

9/22/2011 10:08:00 AM

0

On 22/09/2011 10:37, Catharinus wrote:
> On 22 sep, 11:27, Deanna Earley<dee.ear...@icode.co.uk> wrote:
>> On 22/09/2011 10:15, Catharinus wrote:
>>
>>
>>
>>
>>
>>> Hello my friends
>>> I have a texbox in which I want to insert, delete or update text.
>>> I want to disable the keyascii = 46 (the delete-button)
>>
>>> I use the subrouitine Text1_keypress (keyascii as integer)
>>> It contains, among more things,. the following code:
>>
>>> select case keyascii
>>
>>> 'case 9, 13, 27
>>> keyascii = 0
>>> case 8
>>> code for the backspace key
>>> else
>>> text1.text=text1.text& chr(keyascii)
>>> end case
>>
>>> But the keyascii = 46 does not work in this.
>>> Any idea??
>>
>> Ignore your sample code being invalid, you should be checking for the
>> control character keys in the KeyDown event and check for the
>> appropriate KeyCode.
>> If it's one you want to block, just set it to 0 and leave the rest to
>> the control.
>
> Doing so causes the deletion of part of the text in the textbox
> Any idea?

Doing what?
This works for me to drop delete and backspace.

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDelete Then KeyCode = 0
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then KeyAscii = 0
End Sub

--
Dee Earley (dee.earley@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk...

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)

catharinus

9/22/2011 10:22:00 AM

0

On 22 sep, 12:08, Deanna Earley <dee.ear...@icode.co.uk> wrote:
> On 22/09/2011 10:37, Catharinus wrote:
>
>
>
>
>
> > On 22 sep, 11:27, Deanna Earley<dee.ear...@icode.co.uk>  wrote:
> >> On 22/09/2011 10:15, Catharinus wrote:
>
> >>> Hello my friends
> >>> I have a texbox in which I want to insert, delete or update text.
> >>> I want to disable the keyascii = 46 (the delete-button)
>
> >>> I use the subrouitine Text1_keypress (keyascii as integer)
> >>> It contains, among more things,. the following code:
>
> >>> select case keyascii
>
> >>> 'case 9, 13, 27
> >>>       keyascii = 0
> >>> case 8
> >>>      code for the backspace key
> >>> else
> >>>       text1.text=text1.text&    chr(keyascii)
> >>> end case
>
> >>> But the keyascii = 46 does not work in this.
> >>> Any idea??
>
> >> Ignore your sample code being invalid, you should be checking for the
> >> control character keys in the KeyDown event and check for the
> >> appropriate KeyCode.
> >> If it's one you want to block, just set it to 0 and leave the rest to
> >> the control.
>
> > Doing so causes the deletion of part of the text in the textbox
> > Any idea?
>
> Doing what?
> This works for me to drop delete and backspace.
>
> Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
>    If KeyCode = vbKeyDelete Then KeyCode = 0
> End Sub
>
> Private Sub Text1_KeyPress(KeyAscii As Integer)
>    If KeyAscii = 8 Then KeyAscii = 0
> End Sub
>
> --
> Dee Earley (dee.ear...@icode.co.uk)
> i-Catcher Development Teamhttp://www.icode.co.uk...
>
> iCode Systems
>
> (Replies direct to my email address will be ignored.
> Please reply to the group.)- Tekst uit oorspronkelijk bericht niet weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -

I am sorry. You're right, It looks I am doing something wrong.
Thanks

Henning

9/22/2011 10:46:00 AM

0


"Catharinus" <csvanderwerf@planet.nl> skrev i meddelandet
news:85b3e881-9fda-4ece-8b10-5f91f5268865@i21g2000yqk.googlegroups.com...
On 22 sep, 12:08, Deanna Earley <dee.ear...@icode.co.uk> wrote:
> On 22/09/2011 10:37, Catharinus wrote:
>
>
>
>
>
> > On 22 sep, 11:27, Deanna Earley<dee.ear...@icode.co.uk> wrote:
> >> On 22/09/2011 10:15, Catharinus wrote:
>
> >>> Hello my friends
> >>> I have a texbox in which I want to insert, delete or update text.
> >>> I want to disable the keyascii = 46 (the delete-button)
>
> >>> I use the subrouitine Text1_keypress (keyascii as integer)
> >>> It contains, among more things,. the following code:
>
> >>> select case keyascii
>
> >>> 'case 9, 13, 27
> >>> keyascii = 0
> >>> case 8
> >>> code for the backspace key
> >>> else
> >>> text1.text=text1.text& chr(keyascii)
> >>> end case
>
> >>> But the keyascii = 46 does not work in this.
> >>> Any idea??
>
> >> Ignore your sample code being invalid, you should be checking for the
> >> control character keys in the KeyDown event and check for the
> >> appropriate KeyCode.
> >> If it's one you want to block, just set it to 0 and leave the rest to
> >> the control.
>
> > Doing so causes the deletion of part of the text in the textbox
> > Any idea?
>
> Doing what?
> This works for me to drop delete and backspace.
>
> Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
> If KeyCode = vbKeyDelete Then KeyCode = 0
> End Sub
>
> Private Sub Text1_KeyPress(KeyAscii As Integer)
> If KeyAscii = 8 Then KeyAscii = 0
> End Sub
>
> --
> Dee Earley (dee.ear...@icode.co.uk)
> i-Catcher Development Teamhttp://www.icode.co.uk...
>
> iCode Systems
>
> (Replies direct to my email address will be ignored.
> Please reply to the group.)- Tekst uit oorspronkelijk bericht niet
> weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -

I am sorry. You're right, It looks I am doing something wrong.
Thanks

Dumb? question, have you set the Form KeyPreview property to True?

/Henning