D delta Member Apr 22, 2021 #1 in userform1 in textbox1 contain code for user enter only 10 digit number. but problem is when userform close then message box show textbox1 enter only 10 digit no what is incorrect in this code i attache the sample file Attachments Correct_Code.xlsm 26.8 KB · Views: 1
in userform1 in textbox1 contain code for user enter only 10 digit number. but problem is when userform close then message box show textbox1 enter only 10 digit no what is incorrect in this code i attache the sample file
Hui Excel Ninja Staff member Apr 22, 2021 #2 Your line If IsNumeric(Me.TextBox1.Value) And Len(Me.TextBox1.Value) = 10 Then says if the Textbox is Numeric and if the Length of the value in Textbox 1 =10 then exit the sub But seeing neither are true it doesnt exit and re-asks for input Enter a value of 1234567890 and press exit and it works as written You need to decide what you want to allow as an exit
Your line If IsNumeric(Me.TextBox1.Value) And Len(Me.TextBox1.Value) = 10 Then says if the Textbox is Numeric and if the Length of the value in Textbox 1 =10 then exit the sub But seeing neither are true it doesnt exit and re-asks for input Enter a value of 1234567890 and press exit and it works as written You need to decide what you want to allow as an exit