اذهب الي المحتوي
أوفيسنا

كيف جعل التكسيت لايقبل اكثر من 12 رقم


إذهب إلى أفضل إجابة Solved by سليم حاصبيا,

الردود الموصى بها

وعليكم السلام

اكتب فى خاصيه Maxlenght  رقم 12 

مع وجود هذا الكود داخل التكست بوكس حتى لا يقبل سوى ارقام

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    If KeyAscii > Asc("9") Or KeyAscii < Asc("0") Then
        If KeyAscii = Asc("-") Then
            If InStr(1, Me.TextBox1.Text, "-") > 0 Or _
               Me.TextBox1.SelStart > 0 Then KeyAscii = 0
        ElseIf KeyAscii = Asc(".") Then
            If InStr(1, Me.TextBox1.Text, ".") > 0 Then KeyAscii = 0
        Else
            KeyAscii = 0
        End If
    End If
End Sub

أو فقط هذا الكود لو حابب تكتب أرقام وحروف مثلا

Private Sub TextBox1_Change()
MaxLength = 12
End Sub

1.xls

  • Like 2
رابط هذا التعليق
شارك

  • أفضل إجابة

بعد اذن الاساتذة

كود على السريع

Private Sub TextBox1_Change()
Application.EnableEvents = False
    If TextBox1.TextLength > 12 Then
        MsgBox "Too long Expression"
        TextBox1 = vbNullString
    End If
Application.EnableEvents = True
End Sub

 

  • Like 2
رابط هذا التعليق
شارك

لأنك لم تقم أستاذ محمد بعمل ما أبلغتك به فالملف يعمل معى بكل كفاءة 

فيبدو  انك اخذت الكود فقط وقمت بلصقه ولكنك لم تنظر وتنتبه  الى الملف

 

Untitled.png

  • Like 3
رابط هذا التعليق
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information