Solved

Textbox to accept only number

Posted on 2016-08-31
5
34 Views
Last Modified: 2016-08-31
Hello,
I have code for the textbox to accept only number but it wont allow the user to copy the text from the textbox.

 Private Sub TxtRefCorr_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TxtRefCorr.KeyPress
        Dim ClsMainForm As New ClsFrmMainLoad
        If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 AndAlso Not IsNumeric(e.KeyChar) Then
            ClsMainForm.FormatMessage(20, "Udate : ", e.KeyChar, "Update")
            e.Handled = True
        End If
    End Sub

Open in new window


Any suggestions.
0
Comment
Question by:RIAS
5 Comments
 
LVL 35

Expert Comment

by:Kimputer
ID: 41777823
Most simple solution would be a copy button next to the textbox. Is that a possibilty for your case (or is it inconvenient or too ugly)?
1
 

Author Comment

by:RIAS
ID: 41777825
Hello,
Thanks but think its not convenient.
0
 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 41777835
then try
Case When string Like '%D[0-9]%D[0-9]%' then 'D'+SUBSTRING(SUBSTRING(string,PATINDEX('%D[0-9]%',string)+1,LEN(string)),PATINDEX('%D[0-9]%',SUBSTRING(string,PATINDEX('%D[0-9]%',string)+1,Len(string)))+1,6) ELSE  Null END

Open in new window

Regards
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 41777899
If the Textbox can accept only Numbers, why not use a NumericUpDown control? That control allows users to either enter a number, or use the up/down buttons to scroll through and select a number.
0
 

Author Comment

by:RIAS
ID: 41777902
Thanks Kim
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question