tough textbox question 
Author Message
 tough textbox question

Hello,

How can I prevent a user from pasting information into a textbox?  I
have a very standard user information form (e.g., name, address, etc.)
and have pretty much covered my bases, but I can't seem to figure this
out.

Thanks,
SMH

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Thu, 17 Apr 2003 22:31:52 GMT  
 tough textbox question

schreibt:

Quote:
> Hello,

> How can I prevent a user from pasting information into a textbox?  I
> have a very standard user information form (e.g., name, address, etc.)
> and have pretty much covered my bases, but I can't seem to figure this
> out.

Sett the TextBox's "Locked" property to True.  This will prevent the
user from changing the text in the textbox.

:)      the Christian Privateer     :) Company: ppse.org
:)          aka Jack Voltz          :) Home page: ppse.org/me
:)   M  A  R  A  N  A  T  H  A  !   :) Prolife: ppse.org/prolife
:) S i e m p r e  P o r   V i d a ! :) Music: ppse.org/music
;)       Pour la Vie, toujours !    :)
;)         Sempre per la Vita!      :)  
;)          Semper Pro Vita!        :)
;)  A L W A Y S   P R O   L I F E ! :)


Fri, 18 Apr 2003 00:54:52 GMT  
 tough textbox question
Have you tried setting the Locked property to True?

--
David Oubre


Quote:
> Hello,

> How can I prevent a user from pasting information into a textbox?  I
> have a very standard user information form (e.g., name, address, etc.)
> and have pretty much covered my bases, but I can't seem to figure this
> out.

> Thanks,
> SMH

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Fri, 18 Apr 2003 01:12:12 GMT  
 tough textbox question

Pete))'s wild thoughts were released on Sun, 29 Oct 2000
16:54:52 GMT bearing the following fruit:

Quote:

>schreibt:

>> Hello,

>> How can I prevent a user from pasting information into a textbox?  I
>> have a very standard user information form (e.g., name, address, etc.)
>> and have pretty much covered my bases, but I can't seem to figure this
>> out.
>Sett the TextBox's "Locked" property to True.  This will prevent the
>user from changing the text in the textbox.

Surely, the user wouldn't be able to type anything into the
textbox either?

I guess you could do it with subclassing but I'm not the one
to explain subclassing.

<SNIP EXCESSIVE SIG>

J



Fri, 18 Apr 2003 16:54:17 GMT  
 tough textbox question
Why would you want to stop a user from pasting text into a textbox?

- Jim


Quote:

> Hello,

> How can I prevent a user from pasting information into a textbox?  I
> have a very standard user information form (e.g., name, address, etc.)
> and have pretty much covered my bases, but I can't seem to figure this
> out.

> SMH

Sent via Deja.com http://www.deja.com/
Before you buy.


Fri, 18 Apr 2003 23:04:15 GMT  
 tough textbox question

Quote:

> Hello,

> How can I prevent a user from pasting information into a textbox?  I
> have a very standard user information form (e.g., name, address, etc.)
> and have pretty much covered my bases, but I can't seem to figure this
> out.

Hi SMH-

Just an untested theory, but how about clearing the contents of the
Clipboard whenever the Textbox has focus?
That way, users could still type into the UNLOCKED textbox, but any
pasting would result in a blank.
Worth a try at least...just make sure that the textbox is not the
default focus item when the form is loaded.
Or, maybe you could set a static flag to indicate whether it's been
cleared, so you don't get stuck in a loop.

Private Sub Text1_GotFocus()  
  If Clipboard.GetText(vbCFText) <> "" Then
     Clipboard.Clear
  End If        
End Sub

Later,

Randy Barrow
--

==============================================
Please remove NOSPAM from address for replies
==============================================



Fri, 18 Apr 2003 23:21:24 GMT  
 tough textbox question
Randy,

Damn good idea!  It worked.  Thanks a bunch.

SMH



Quote:

> > Hello,

> > How can I prevent a user from pasting information into a textbox?  I
> > have a very standard user information form (e.g., name, address,
etc.)
> > and have pretty much covered my bases, but I can't seem to figure
this
> > out.

> Hi SMH-

> Just an untested theory, but how about clearing the contents of the
> Clipboard whenever the Textbox has focus?
> That way, users could still type into the UNLOCKED textbox, but any
> pasting would result in a blank.
> Worth a try at least...just make sure that the textbox is not the
> default focus item when the form is loaded.
> Or, maybe you could set a static flag to indicate whether it's been
> cleared, so you don't get stuck in a loop.

> Private Sub Text1_GotFocus()
>   If Clipboard.GetText(vbCFText) <> "" Then
>      Clipboard.Clear
>   End If
> End Sub

> Later,

> Randy Barrow
> --

> ==============================================
> Please remove NOSPAM from address for replies
> ==============================================

Sent via Deja.com http://www.deja.com/
Before you buy.


Sat, 19 Apr 2003 01:11:30 GMT  
 tough textbox question

Quote:
> Damn good idea!  It worked.  Thanks a bunch.

What happens if the text box already has the focus, the user copies text
from another app, and then returns to your app and pastes it in?  If the
clipboard is only cleared when the text box gets the focus, this will get
around the solution.

Besides, this is a non-standard windows programming technique.  If you were
to release your app, users would be wondering why the graphics data they
copied from a paint program disappears when they go to your rogue text box
and then back to the paint program (I know this is hypothetical, but it
could, and will happen).  More likely, they will think it is a bug in
Windows itself because they have no idea that your text box clears the
clipboard.

You can use the KeyPress event to trap Ctrl+X, C and V, but I'm not sure
about Shift+Insert, Shift+Delete and Ctrl+Insert.

Anyway, the proper solution may be long and tedious, but is worth it in the
long run.



Sat, 19 Apr 2003 03:13:18 GMT  
 tough textbox question

Quote:
>> Damn good idea!  It worked.  Thanks a bunch.

>What happens if the text box already has the focus, the user copies text
>from another app, and then returns to your app and pastes it in?  If the
>clipboard is only cleared when the text box gets the focus, this will get
>around the solution.

>Besides, this is a non-standard windows programming technique.  If you were
>to release your app, users would be wondering why the graphics data they
>copied from a paint program disappears when they go to your rogue text box
>and then back to the paint program (I know this is hypothetical, but it
>could, and will happen).  More likely, they will think it is a bug in
>Windows itself because they have no idea that your text box clears the
>clipboard.

>You can use the KeyPress event to trap Ctrl+X, C and V, but I'm not sure
>about Shift+Insert, Shift+Delete and Ctrl+Insert.

>Anyway, the proper solution may be long and tedious, but is worth it in the
>long run.

I think I might have another unorthadox solution to try.  Try this:

Public Blah As String

Private Sub Text1_Change()
If Len(Text1.Text) > Len(Blah) + 1 Then
    Text1.Text = Blah
    Text1.SelStart = Len(Blah) + 1
Else
    Blah = Text1.Text
End If

End Sub

This works on the assumption that you can't normally type more than one
character at a time. (But, of course, this won't work if there's only one
character on the clipboard...) :-)

Jeremiah



Mon, 21 Apr 2003 08:15:23 GMT  
 tough textbox question
Huh?  You want to deliberately destroy the user's data without warning
and without confirmation?  No wonder VB programmers get such a bad rap.

- Jim



Quote:

> > Hello,

> > How can I prevent a user from pasting information into a textbox?  I
> > have a very standard user information form (e.g., name, address,
etc.)
> > and have pretty much covered my bases, but I can't seem to figure
this
> > out.

> Hi SMH-

> Just an untested theory, but how about clearing the contents of the
> Clipboard whenever the Textbox has focus?
> That way, users could still type into the UNLOCKED textbox, but any
> pasting would result in a blank.
> Worth a try at least...just make sure that the textbox is not the
> default focus item when the form is loaded.
> Or, maybe you could set a static flag to indicate whether it's been
> cleared, so you don't get stuck in a loop.

> Private Sub Text1_GotFocus()
>   If Clipboard.GetText(vbCFText) <> "" Then
>      Clipboard.Clear
>   End If
> End Sub

> Later,

> Randy Barrow

Sent via Deja.com http://www.deja.com/
Before you buy.


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. tough question for gurus!

2. Tough questions...

3. Mathmatical Genious Needed for this tough question

4. TOUGH Question - Late Bound COM objects and VB.NET

5. tough question for powerbasic

6. a few tough questions

7. a few tough questions

8. REALLY TOUGH QUESTION

9. A tough question - but interesting...

10. Animated GIF's - Tough Question

11. I think this is a TOUGH question...

12. Winamp VB Tough Question

 

 
Powered by phpBB® Forum Software