Hello,
I have 5 textbox from text1 to text5 i have a button of
clear wht i want is to clear text box if my foucs is on text3 i
want to clear that text not other is it possiobe to do like
Regards
Printable View
Hello,
I have 5 textbox from text1 to text5 i have a button of
clear wht i want is to clear text box if my foucs is on text3 i
want to clear that text not other is it possiobe to do like
Regards
Hi
yeah u sure can do that. I have shown 2 methods. The first one is your situation where each textbox is named differentlyeg Text1, Text2, Text3 etc .The second one shows how much easier it is if u use a control array eg Text1(0), Text1(1), Text1(2) etc... A control array is just the same control copied over and over with a new Index property each time.
VB Code:
Dim TheActiveControl As Control Private Sub Command1_Click() TheActiveControl.Text = "" End Sub Private Sub Text1_GotFocus() Set TheActiveControl = Text1 End Sub Private Sub Text2_GotFocus() Set TheActiveControl = Text2 End Sub Private Sub Text3_GotFocus() Set TheActiveControl = Text3 End Sub Private Sub Text4_GotFocus() Set TheActiveControl = Text4 End Sub Private Sub Text5_GotFocus() Set TheActiveControl = Text5 End SubRegardsVB Code:
Dim ActiveBox As Integer Private Sub Command1_Click() Text1(ActiveBox).Text = "" End Sub Private Sub Text1_GotFocus(Index As Integer) ActiveBox = Index End Sub
Stuart