Results 1 to 5 of 5

Thread: Check is something exists

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2006
    Posts
    221

    Check is something exists

    I have items in a control array which are made when the program is running. Is there a way for me to check if a certain one exists?

  2. #2
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Check is something exists

    while creating controls dynamically you know what you create Right! then why do you want to check again what controls available.

    I mean, you know what you are doing? So, I think there is no need to check once again.
    CS

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2006
    Posts
    221

    Re: Check is something exists

    the code needs to go:

    VB Code:
    1. if [item] exists then
    2.  
    3. 'things
    4.  
    5. end if

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Check is something exists

    VB Code:
    1. Dim ctl As Control
    2.  
    3. For Each ctl In Controls
    4.     If ctl.Name = <the name of the control array> Then
    5.         If ctl.Index = 4 Then ' or whichever one you are looking for
    6.             MsgBox "it exists"
    7.         End If
    8.     End If
    9. Next

  5. #5
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Check is something exists

    or, to save looping through unnecessary controls:
    VB Code:
    1. Dim ctl As Control
    2.  
    3. For Each ctl In ctlArray
    4.     If ctl.Index = 4 Then ' or whichever one you are looking for
    5.         MsgBox "it exists"
    6.         Exit For
    7.     End If
    8. Next ctl

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