473,395 Members | 1,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to disable pasting special characters in text box?

Hi guys...

I am using a text box in vb6 application and I have applied validations on it such that it will only accept Numeric data through keyboard.
But the problem is when I try to paste some special characters in it through Mouse Right Click, it gets pasted from clip board.
It happens because I have applied validations on Keypress event.
Let me tell u that CTRL+V (paste through keyboard is also disabled).
Now what I want is either I should trap the Mouse right click event and check if "Paste" option is selected, if it is true then I can use "isnumeric(Clipboard.GetText())" and read data from clipboard and prompt a message that non numeric data present on clip board.
If button = vbRightclick then
Feb 27 '07 #1
7 11337
vijaydiwakar
579 512MB
Hi guys...

I am using a text box in vb6 application and I have applied validations on it such that it will only accept Numeric data through keyboard.
But the problem is when I try to paste some special characters in it through Mouse Right Click, it gets pasted from clip board.
It happens because I have applied validations on Keypress event.
Let me tell u that CTRL+V (paste through keyboard is also disabled).
Now what I want is either I should trap the Mouse right click event and check if "Paste" option is selected, if it is true then I can use "isnumeric(Clipboard.GetText())" and read data from clipboard and prompt a message that non numeric data present on clip board.
If button = vbRightclick then
just lock the textbox in keydown event txt have the property use it
Feb 27 '07 #2
thnx dude I tried same but I need to enter numeric data through keyboard, if we will lock text box it will create problem.
what I thought is to trap the default menu editor and check if the menu item selected is "Paste", if true then we can check data on clipboard if it is numeric then proceed else show msg of invalid data on clip board.
In this implementation I m having problem that I m not able to trap default menu editor and the click of "Paste " option.
can u suggest anything in this respect...
Feb 27 '07 #3
vijaydiwakar
579 512MB
thnx dude I tried same but I need to enter numeric data through keyboard, if we will lock text box it will create problem.
what I thought is to trap the default menu editor and check if the menu item selected is "Paste", if true then we can check data on clipboard if it is numeric then proceed else show msg of invalid data on clip board.
In this implementation I m having problem that I m not able to trap default menu editor and the click of "Paste " option.
can u suggest anything in this respect...
See I'll give u d code tommoro b'coz it's my time to go home so tomoro when i will come i'll give u d code
Trust me
both Ctrl+V and menu Paste will be get disabled
Trust me
Feb 27 '07 #4
Killer42
8,435 Expert 8TB
You could try a simple brute-force approach. In the Change event, just go through the .Text property and remove any non-numeric characters.
Feb 27 '07 #5
vijaydiwakar
579 512MB
Hi guys...

I am using a text box in vb6 application and I have applied validations on it such that it will only accept Numeric data through keyboard.
But the problem is when I try to paste some special characters in it through Mouse Right Click, it gets pasted from clip board.
It happens because I have applied validations on Keypress event.
Let me tell u that CTRL+V (paste through keyboard is also disabled).
Now what I want is either I should trap the Mouse right click event and check if "Paste" option is selected, if it is true then I can use "isnumeric(Clipboard.GetText())" and read data from clipboard and prompt a message that non numeric data present on clip board.
If button = vbRightclick then
dear i'm with d sol. just try it
Expand|Select|Wrap|Line Numbers
  1. Private Sub Text1_KeyPress(KeyAscii As Integer)
  2.     CheckCopyPaste Text1, KeyAscii
  3. End Sub
  4.  
  5. Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  6.     CheckCopyPaste Text1, Button
  7. End Sub
  8.  
  9. Public Sub CheckCopyPaste(txtbox As Object, KeyCode As Integer)
  10.     If KeyCode <> 22 And KeyCode <> 93 And KeyCode <> 2 Then
  11.         txtbox.Locked = False
  12.     Else
  13.         txtbox.Locked = True
  14.     End If
  15. End Sub
  16.  
Feb 28 '07 #6
Can u not use richtext box tool
Feb 28 '07 #7
Killer42
8,435 Expert 8TB
Can u not use richtext box tool
While we're on the subject, what about the Masked Edit control?
Feb 28 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Lisa | last post by:
I need to apply the HTML formatting tags and the French accented characters in a XML document. The XML is generated from a database that has HTML tags and French accented characters in the records....
0
by: jinu | last post by:
Hello, Facing a problem where I use a numericupdown control in vb.net for recieving an input. But user can copy a "text" using mouse and paste into the numericupdown control. This will lead to...
5
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API function gives an error as "Unable to open input file"....
2
by: Steve | last post by:
Hi all, Is it possible to disable pasting from the clipboard into a textbox ?? I can't find a property for it but I guess it must be possible. thanks Steve
16
by: MLH | last post by:
If I give someone a runtime app, they can open the database window by pressing the F-11 key. How to prevent???
8
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box...
1
by: sonald | last post by:
Dear All, I am working on a module that validates the provided CSV data in a text format, which must be in a predefined format. We check for the : 1. Number of fields provided in the text file,...
4
by: Jon | last post by:
Hi, I used XslCompiledTransform with the following Xsl file. The <xsl:text disable-output-escaping="yes"does not work when using XslCompiledTransform to do the trnasform (namely the output...
6
by: =?Utf-8?B?TWljaGFlbCAwMw==?= | last post by:
I need to disable the clipboard function in Windows XP. We are having a problem with users using CTRL+C in one program, then using CTRL+V in another. Specifically, they type their password into...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.