تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
كود لجعل أداة النص لا تقبل إلا الأرقام
#8
تفضل أخي الكريم

كود :
Private FunctionCopyPasteCut As Boolean = False
    Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
        Select Case e.KeyData
            Case 131158
                ' "Paste"
                If IsNumeric(Clipboard.GetText) Then FunctionCopyPasteCut = True
            Case 131160
                ' "Cut"
                FunctionCopyPasteCut = True
            Case 131139
                ' "Copy"
                FunctionCopyPasteCut = True
        End Select
    End Sub
    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If FunctionCopyPasteCut = True Then
            FunctionCopyPasteCut = False
            Exit Sub
        End If
        If Not IsNumeric(e.KeyChar) Then
            If Not Asc(e.KeyChar) = Keys.Back [color=#FF0000]AndAlso Not e.KeyChar = "."[/color] Then
                e.Handled = True
            End If
        End If
    End Sub

لاحظ الجملة الحمراء التي تم إضافتها
وهكذا فإنك تستطيع إضافة أي رمز تريد بنفس الطريقة
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
كود لجعل أداة النص لا تقبل إلا الأرقام - بواسطة sooriaty03 - 23-11-12, 02:14 PM


التنقل السريع :


يقوم بقرائة الموضوع: