• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

vbYesNo

mahaveer

Member
I have put the following code m i right ?

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)

msgbox "Do you want to add one more text box",vbYesNo

If ans = Yes then

textbox3.visible = true

textbox3.setfocus

else

commandbutton1.setfocus

end if

end if

End Sub


If i m right then why i am receiving msgbox 2 time when i exit from textbox1?


Thank You
 
Hi Mahaveer ,


Change your statements :

[pre]
Code:
msgbox "Do you want to add one more text box",vbYesNo
If ans = Yes then
to

ans = MsgBox ("Do you want to add one more text box ?" , vbYesNo)
If ans = vbYes Then
[/pre]
Narayan
 
thanks narayank

but if i have 20 textbox like this but only textbox1 is visible and remaining are hides

now the same question i want to ask every time when every textbox exits therefore

should i write the code 20 times?
 
Hi Mahaveer ,


I think you asked a similar question earlier , and Luke has replied that if you used Classes , you would not have to replicate the code 20 times ; if you already have such repeated code , then yes , you will have to write the above code 20 times.


Narayan
 
Good day mahaveer


You may find this link of help with VBA classes


http://www.cpearson.com/excel/classes.aspx
 
Back
Top