Solved

Textbox to accept only number

Posted on 2016-08-31
5
31 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 49

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

932 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now