473,802 Members | 1,986 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to disable pasting special characters in text box?

7 New Member
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(Clip board.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 11425
vijaydiwakar
579 Contributor
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(Clip board.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
PrateekArora
7 New Member
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 Contributor
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 Recognized Expert Expert
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 Contributor
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(Clip board.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
ChillUmesh
20 New Member
Can u not use richtext box tool
Feb 28 '07 #7
Killer42
8,435 Recognized Expert Expert
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
5582
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. I have specified <xsl:output method="html"/> and encoding="iso-8859-1". When I apply the xsl:value-of and set the disable-output-escaping to "yes", the HTML formatting tags are displayed correctly, but the French accented characters are...
0
1494
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 error while processing inside the application. I have to present the numeric control to the user so as to enter any value he likes "except any text or invalid characters" ( allow numeric values only) Please help. Thanks in advance.
5
8633
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". Same file path containing special characters works fine in one machine, but doesn't work in other. I am using following API function to get short file path. Declare Auto Function GetShortPathName Lib "kernel32" (ByVal lpszLongPath As
2
2967
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
6275
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
3715
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 and save it to a file. This step is not to hard however the contents of the textarea is mostly latex source so it contains just about every special character you can imagine. My question is this, how do I save an exact copy of the textarea...
1
4578
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, 2. Text checks for max. length of the field & whether the field is mandatory or optional Example:
4
9183
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 contain < not <), while it works when using MSXML2 to do the transform. Does anyone have the same problem and how to make the escape work? Thanks. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
6
17794
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 notepad, copy it to the clipboard, then paste it in another program. The other program runs on Windows XP. Obviously, the correct answer is to have the creators of the other program to disable pasting in a password field, but they are reluctant...
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10538
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10305
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10285
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.