Results 1 to 2 of 2

Thread: Clear

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    karachi
    Posts
    90

    Clear

    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

  2. #2
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    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:
    1. Dim TheActiveControl As Control
    2.  
    3. Private Sub Command1_Click()
    4.     TheActiveControl.Text = ""
    5. End Sub
    6.  
    7. Private Sub Text1_GotFocus()
    8.     Set TheActiveControl = Text1
    9. End Sub
    10.  
    11. Private Sub Text2_GotFocus()
    12.     Set TheActiveControl = Text2
    13. End Sub
    14.  
    15. Private Sub Text3_GotFocus()
    16.     Set TheActiveControl = Text3
    17. End Sub
    18.  
    19. Private Sub Text4_GotFocus()
    20.     Set TheActiveControl = Text4
    21. End Sub
    22.  
    23. Private Sub Text5_GotFocus()
    24.     Set TheActiveControl = Text5
    25. End Sub
    VB Code:
    1. Dim ActiveBox As Integer
    2.  
    3. Private Sub Command1_Click()
    4.     Text1(ActiveBox).Text = ""
    5. End Sub
    6.  
    7. Private Sub Text1_GotFocus(Index As Integer)
    8.     ActiveBox = Index
    9. End Sub
    Regards
    Stuart
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width