Using loop in text box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kako0000000
    New Member
    • Aug 2013
    • 6

    Using loop in text box

    Hello I used textbox in my project i write a number and some thing writing i textbox using loop
    for example
    i used this code
    Code:
    Private Sub Command1_Click()
    Dim i As Integer
    For i = 0 To 10
    Text1.Text = "work is great" & i
    Next i
    End Sub
    but when i run program and click button only see result work is great10

    i run
    work is great0
    work is great1
    work is great2
    work is great3
    work is great4
    .
    .
    .
    how can this work in textbox
    Last edited by Rabbit; Dec 19 '13, 04:47 AM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code or formatted data.

    All UI update events are suspended until code has finished running. You need to use a Timer object if you want the UI to update in between each run.

    Comment

    • Flinty
      New Member
      • Jan 2013
      • 11

      #3
      Using loop in textbox

      '
      'add timer control to form
      'set interval to 1500 and enabled = false
      Code:
      Option Explicit
      Dim C
      Private Sub Command1_Click()
          Timer1.Enabled = True
      '
      End Sub
      
      Private Sub Timer1_Timer()
      '
          C = C + 1
             Text1 = "Work is great" & " " & C
              If C >= 11 Then
                  Timer1.Enabled = False
                  Text1 = ""
              End If
      '
      End Sub

      Comment

      Working...