Results 1 to 5 of 5

Thread: how to keep contents of text1 array in sync

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    149

    how to keep contents of text1 array in sync

    I've got a form with an array of text1's. There are three elements in the array.

    I want it so that if you type into any one of them, they all get updated with the same text.

    I've tried this with a loop inside of the "Text1_Change" event but I get a stack overflow for obvious reasons.

    'keep the contents of all textboxes the same:
    Private Sub Text1_Change(Index As Integer)
    Dim i As Integer
    Dim Text1 as string
    Text1= Text1(Index)
    For i = 0 To Text1.ubound
    Text1(i).Text = Text1_Test
    Next i
    End Sub

    (Can't use keydown/keypress events since contents may get changed thru the program also)
    Any ideas??
    Last edited by joblake; Sep 4th, 2002 at 10:17 AM.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    149

    <RESOLVED ??>

    If you think that what I've done SHOULD work, let me know. As I look at it, I think I've got something else that may be wrong.

  3. #3
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    using the change event to instigate a change will invoke the change event which will invoke the change even which will ...

    and you will always get stack overflow.

    set a flag before doing the forced change and test the flag in all change events & if it's on exit immediately, then reset the flag after doing the forced change.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    An example of what phinds described:
    VB Code:
    1. Private Sub Text1_Change(Index As Integer)
    2.  
    3. Dim i As Integer
    4. Dim Text1_test as string
    5.  
    6. Static Changing_in_code as Boolean
    7.  
    8.   If Changing_in_code Then Exit Sub
    9.   Changing_in_code = True
    10.  
    11.   Text1_test= Text1(Index)
    12.   For i = 0 To Text1.ubound
    13.     Text1(i).Text = Text1_Test
    14.   Next i
    15.  
    16.   Changing_in_code = False
    17.  
    18. End Sub

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    149

    great !!

    thanks to you both phinds & geek

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