Solved

Textbox to accept only number

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

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 to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 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

12 Experts available now in Live!

Get 1:1 Help Now