Results 1 to 8 of 8

Thread: Collections

  1. #1

    Thread Starter
    Addicted Member FrEaK85's Avatar
    Join Date
    Apr 2002
    Posts
    153

    Collections

    I need to get all of the richtextboxes on my form:

    VB Code:
    1. Dim rText As RichTextBox
    2. For Each rText In frmNew.Controls
    3.    
    4. Next rText

    doesn't works, gives an "type mismatch" error

    VB Code:
    1. Dim rText As Control
    2. For Each rText In frmNew.Controls
    3.    
    4. Next rText

    does work, but then i get all of my controls

    how do i get only my richtextboxes?

    thanks

  2. #2
    Addicted Member
    Join Date
    Sep 2001
    Location
    Florida
    Posts
    213
    Try
    VB Code:
    1. Dim rText As VB.RichTextBox
    Instead of
    VB Code:
    1. Dim rText As RichTextBox

  3. #3

    Thread Starter
    Addicted Member FrEaK85's Avatar
    Join Date
    Apr 2002
    Posts
    153

    thx for reply

    when i try dim rText as vb. richttextbox isn't there, there's picturebox, textbox, ... but not picturebox

  4. #4
    Addicted Member
    Join Date
    Sep 2001
    Location
    Florida
    Posts
    213
    How did you put the richtexbox on your form?

  5. #5

    Thread Starter
    Addicted Member FrEaK85's Avatar
    Join Date
    Apr 2002
    Posts
    153
    at design time

  6. #6
    Addicted Member
    Join Date
    Sep 2001
    Location
    Florida
    Posts
    213
    Will Dim rText As VB.TextBox work?

    What's the diff between RichTextBox & TextBox?

  7. #7

    Thread Starter
    Addicted Member FrEaK85's Avatar
    Join Date
    Apr 2002
    Posts
    153
    well if you do dim rText as VB.Textbox and then use:
    VB Code:
    1. For Each rText in frmNew.Controls
    2.  
    3. Next rText
    then it would probably take all textboxes if it would work

  8. #8
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    Do this:
    Code:
    Dim rText As Control
    For Each rText In frmNew.Controls
        If TypeName(rText)="RichTextBox" Then
                msgbox "HI"
        End If
    Next rText
    Hope this helps,

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