Slight modification required

NimishK

Well-known Member
Joined
Sep 4, 2015
Messages
684
Hello
Slight modifciation required from below code.
I want to enter the text in textbox with Numeric Values with "-" For eg Date 22-09-2009
what will be the change in the below code to acheive with numeric values and "-"
Code:
   KeyAscii = -KeyAscii * CLng(Chr(KeyAscii) Like "#")
   If KeyAscii = 0 Then Beep

Thanks
NimishK
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
You can try something like this

Code:
Private Sub [COLOR=#ff0000]TextBox2[/COLOR]_Change()
    Dim t As String
    With [COLOR=#ff0000]TextBox2[/COLOR]
        t = .Text
        Select Case Len(t)
            Case 2, 5:          t = t & "-"
            Case Is >= 10:      t = Left(t, 10)
        End Select
        .Text = t
    End With
End Sub

Private Sub [COLOR=#ff0000]TextBox2[/COLOR]_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    With [COLOR=#ff0000]TextBox2[/COLOR]
        Select Case KeyAscii
            Case Asc("0") To Asc("9")
            Case Else: KeyAscii = 0
        End Select
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,815
Messages
6,127,035
Members
449,355
Latest member
g wiggle

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top