Results 1 to 14 of 14

Thread: Select ALL code

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2001
    Posts
    3

    Select ALL code

    Hi,
    I am new in the vb word, and I am trying to add a [Select All](ctl-A) menu selection under the Edit option. Does anyone wrote code for this.
    If you had, could you shared with me. Thanks
    peree1

  2. #2
    Member
    Join Date
    Sep 2001
    Location
    USA
    Posts
    33
    select all what?

    other than that go to Menu Editor (right click on your form) then under Edit hit Insert (make sure it's in the right alignment) then just put in Select &All for the caption and mnuEditSelAll for the name and choose your shortcut from the list. then just click on Edit and Select All in your form and it'll take you to the onClick event and you can put in your code to do whatever

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2001
    Posts
    3
    Thanks shabbs, but I did all you said, what I need is the code that goes under the click event to select all the text on the form, like the select all in any windows screen.
    peree1

  4. #4
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    You can select text in a control, such as a textbox
    VB Code:
    1. Private Sub mnuSelectAll_Click()
    2.  
    3. If TypeOf Screen.ActiveControl Is TextBox Then
    4.     Screen.ActiveControl.SelStart = 0
    5.     Screen.ActiveControl.SelLength = Len(Screen.ActiveControl.Text)
    6. End If
    7.  
    8. End Sub
    mnuSelectAll is a menu item build with VB's Menu Editor

  5. #5
    Member
    Join Date
    Sep 2001
    Location
    USA
    Posts
    33
    Try this

    TextBox.SelStart = 0
    TextBox.SelLength = Length(TextBox.Text)

  6. #6
    Member
    Join Date
    Sep 2001
    Location
    USA
    Posts
    33
    bah, he beat me to it :P how do you do that fancy VB Code quoting though?

  7. #7
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    by putting it in code tags;

    [vbcode]
    Dim i As Long
    ' blah blah blah
    [/vbcode]

    produces
    VB Code:
    1. Dim i As Long
    2. ' blah blah blah

    Incidently, it's Len, not Length and you should use ActiveControl rather than specifying one if it could be any control.

  8. #8
    Member
    Join Date
    Sep 2001
    Location
    USA
    Posts
    33
    picky picky picky

  9. #9
    Matthew Gates
    Guest
    He told you how to do it peree1, just didn't give you the code.


    VB Code:
    1. Private Sub mnuSelectAll_Click()
    2.     With Text1
    3.         .SelLength = 0
    4.         .SelStart = Len(.Text)
    5.         .SetFocus
    6.     End With
    7. End Sub

  10. #10
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Matt, I think we've got the idea

    And don't specify the control!!

  11. #11

    Thread Starter
    New Member
    Join Date
    Oct 2001
    Posts
    3
    Thanks guys, peace for all. ha...
    peree1

  12. #12
    Matthew Gates
    Guest
    Originally posted by chrisjk
    Matt, I think we've got the idea

    And don't specify the control!!

    You may have the idea, but at the time when I posted a reply, there were no replies other than peree1's second post in this thread.

  13. #13
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    okay, apologies all-round, but there was 5 minutes between my first and yours

  14. #14
    Matthew Gates
    Guest
    Originally posted by chrisjk
    okay, apologies all-round, but there was 5 minutes between my first and yours

    I open about 5-10 threads at a time, click reply to the ones I know, answer them all, and by the time I get back to the one, like this one, it's already been answered, sorry about that, just many more people on the boards now than there was 1 year ago.

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