CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Guest

    collection control

    Hi all,

    I want to clear all text box in my form.
    dim ctl as control
    for each ctl in control
    if typeof ctl Is TextBox then
    ctl.text = ""
    end if
    next


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: collection control

    pretty close

    dim ctl as control
    for each ctl in me.controls
    if typeof ctl is TextBox then
    ctl.text = ""
    end if
    next ctl






  3. #3
    Join Date
    Jun 1999
    Location
    Switzerland
    Posts
    58

    Re: collection control

    dim ctl as control
    for each ctl in form1.controls ' or me.controls
    if typeof ctl Is TextBox then
    ctl.text = ""
    end if
    next

    _________

    Mark my slight correction <form1.controls> or
    <me.controls>

    Jan


  4. #4
    Join Date
    Jun 1999
    Location
    Switzerland
    Posts
    58

    Re: collection control/ I forgot

    Sorry I didn't see Lothar's reply earlier;
    I forgot to add <ctr> to next..so--> next ctr
    Do as Lothar suggested

    Jan



  5. #5
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: collection control/ I forgot

    Is there any reason for adding the ctl in :

    next Ctl



    apart from readability purposes. I only ever mark my 'Next' statements if they are embedded within other 'For' loops and haven't had a problem yet (in-fact, it doesn't matter if you don't mark them when they're embedded).


    Just wondering...



    Chris Eastwood

    CodeGuru - the website for developers
    http://www.codeguru.com/vb

  6. #6
    Join Date
    May 1999
    Posts
    3,332

    Re: collection control/ I forgot

    even worse, if you switch between VB and VBScript as I often have to do, VBScript will complain about the "next i", because it doesn't support that (might have changed in Version 5 for IE 5).


  7. #7
    Join Date
    Jun 1999
    Location
    Switzerland
    Posts
    58

    Re: collection control/ I forgot

    The reaon to add "ctr" after <next>?

    More matter of habit.However, it's not necessary at least in VB6 (my experience), I admit.
    Thanks Chris.

    Jan


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

Featured