Link to home
Start Free TrialLog in
Avatar of RIAS
RIASFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Textbox to accept only number

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.
Avatar of Kimputer
Kimputer

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)?
Avatar of RIAS

ASKER

Hello,
Thanks but think its not convenient.
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
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RIAS

ASKER

Thanks Kim