Solved

Textbox to accept only number

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

786 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