+ Reply to Thread
Results 1 to 5 of 5

Form

  1. #1
    Bill
    Guest

    Form

    Hello,
    I have a form that contains a number of text boxes. I would like to add a
    loop that sets each text box to an initial value such as 1. Each textbox is
    cleverly names TextBox1, TextBox2. I tried a loop like:

    For i = 1 to 10
    userform1.textbox " & i = 1
    next i

    But that doesn't work. Any help?

    Thanks.

    Bill



  2. #2
    Duncan
    Guest

    Re: Form

    For Each cntrl In Me.Controls
    On Error Resume Next
    If TypeOf cntrl Is MSForms.TextBox Then
    cntrl.Value = "1"
    End If
    Next cntrl


    I think this should do it, havent tested though so post back and let us
    know either way.

    Duncan


    Bill wrote:

    > Hello,
    > I have a form that contains a number of text boxes. I would like to add a
    > loop that sets each text box to an initial value such as 1. Each textbox is
    > cleverly names TextBox1, TextBox2. I tried a loop like:
    >
    > For i = 1 to 10
    > userform1.textbox " & i = 1
    > next i
    >
    > But that doesn't work. Any help?
    >
    > Thanks.
    >
    > Bill



  3. #3
    Norman Jones
    Guest

    Re: Form

    Hi Bill,

    Try:

    For i = 1 to 10
    Userform1.Controls("Textbox" & i).Text = ""
    Next i



    ---
    Regards,
    Norman



    "Bill" <bill@bpiconsulting.com> wrote in message
    news:8z8pg.536$cd3.237@newsread3.news.pas.earthlink.net...
    > Hello,
    > I have a form that contains a number of text boxes. I would like to add a
    > loop that sets each text box to an initial value such as 1. Each textbox
    > is cleverly names TextBox1, TextBox2. I tried a loop like:
    >
    > For i = 1 to 10
    > userform1.textbox " & i = 1
    > next i
    >
    > But that doesn't work. Any help?
    >
    > Thanks.
    >
    > Bill
    >




  4. #4
    Bill
    Guest

    Re: Form

    Worked great. Thanks!

    "Duncan" <duncan.mutchblache@googlemail.com> wrote in message
    news:1151669825.270443.252630@p79g2000cwp.googlegroups.com...
    > For Each cntrl In Me.Controls
    > On Error Resume Next
    > If TypeOf cntrl Is MSForms.TextBox Then
    > cntrl.Value = "1"
    > End If
    > Next cntrl
    >
    >
    > I think this should do it, havent tested though so post back and let us
    > know either way.
    >
    > Duncan
    >
    >
    > Bill wrote:
    >
    >> Hello,
    >> I have a form that contains a number of text boxes. I would like to add
    >> a
    >> loop that sets each text box to an initial value such as 1. Each textbox
    >> is
    >> cleverly names TextBox1, TextBox2. I tried a loop like:
    >>
    >> For i = 1 to 10
    >> userform1.textbox " & i = 1
    >> next i
    >>
    >> But that doesn't work. Any help?
    >>
    >> Thanks.
    >>
    >> Bill

    >




  5. #5
    Duncan
    Guest

    Re: Form

    Bill,

    If you was saying that my loop worked then I just point out, using this
    way means you can change the names of the textboxes, and can add more
    without affecting the loop.

    But both ways work just the same, a case of whether you want certain
    textboxes excluded from your loop really.

    Duncan




    Bill wrote:

    > Worked great. Thanks!
    >
    > "Duncan" <duncan.mutchblache@googlemail.com> wrote in message
    > news:1151669825.270443.252630@p79g2000cwp.googlegroups.com...
    > > For Each cntrl In Me.Controls
    > > On Error Resume Next
    > > If TypeOf cntrl Is MSForms.TextBox Then
    > > cntrl.Value = "1"
    > > End If
    > > Next cntrl
    > >
    > >
    > > I think this should do it, havent tested though so post back and let us
    > > know either way.
    > >
    > > Duncan
    > >
    > >
    > > Bill wrote:
    > >
    > >> Hello,
    > >> I have a form that contains a number of text boxes. I would like to add
    > >> a
    > >> loop that sets each text box to an initial value such as 1. Each textbox
    > >> is
    > >> cleverly names TextBox1, TextBox2. I tried a loop like:
    > >>
    > >> For i = 1 to 10
    > >> userform1.textbox " & i = 1
    > >> next i
    > >>
    > >> But that doesn't work. Any help?
    > >>
    > >> Thanks.
    > >>
    > >> Bill

    > >



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1