Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Textbox Exit Event (MSForms 2.0)

    Is there a way to expose the textbox Enter and Exit events in a class module? If I put
    <pre>Public WithEvents TextCtrl As MSForms.TextBox</pre>

    at the top of my class module, then in the Object drop-down I have an object TextCtrl, and with this object I have lots of events in the Procedure drop-down, Change, KeyDown, etc, but ther is no Enter or Exit event. Why not? How can you do validity-checking on the textbox without the Exit event? TIA --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Textbox Exit Event (MSForms 2.0)

    Sam,
    Unlike a userform textbox, a MSFORMS textbox does not support those events.

    (That's what I conclude, anyway.)
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Textbox Exit Event (MSForms 2.0)

    A UserForm textbox is an MSForms textbox.
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Textbox Exit Event (MSForms 2.0)

    What kind of form is created by Insert>Textbox?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  5. #5
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Textbox Exit Event (MSForms 2.0)

    Well, then why not create the event code anyway and see what happens.

    The object Browser shows no Enter or Exit events for the MSForms Textbox, but those
    events are available in any text box on a form. Beats me.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  6. #6
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Textbox Exit Event (MSForms 2.0)

    > What kind of form is created by Insert>Textbox
    Excel.Textbox, I'm not using them. All the textboxes are on a Userform.

    > why not create the event code anyway and see what happens
    never fires <img src=/S/doh.gif border=0 alt=doh width=15 height=15>

    > The object Browser shows no Enter or Exit events
    <img src=/S/yep.gif border=0 alt=yep width=15 height=15> they are in MSForms.Control
    but, when I tried to use MSForms.Control in my class module, I got an automation error. <img src=/S/stupidme.gif border=0 alt=stupidme width=30 height=30>

    Looks like it can't be done. --Sam <img src=/S/weep.gif border=0 alt=weep width=21 height=16>
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  7. #7
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Textbox Exit Event (MSForms 2.0)

    Maybe our differences are due to the fact that you're working in Excel
    and I'm testing in Word ??
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  8. #8
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Textbox Exit Event (MSForms 2.0)

    No, it's the same in Word, except Insert > Textbox gives a Word.Textbox. The Exit event is still in MSForms.Control.
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  9. #9
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Textbox Exit Event (MSForms 2.0)

    Show me.
    Attached Images Attached Images
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  10. #10
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Textbox Exit Event (MSForms 2.0)

    How is a Control a Textbox?

    Does Control mean "All controls (regardless of type) have these events, properties and methods"?

    Bear with me. I'm a larnin' here...
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  11. #11
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Textbox Exit Event (MSForms 2.0)

    Just search for Control
    edited to make a better picture
    Attached Images Attached Images
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  12. #12
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Textbox Exit Event (MSForms 2.0)

    > Does Control mean "All controls (regardless of type) have these events, properties and methods"?
    Beats me, but totally unencombered by knowledge, I think so. Just hold on, I'm moving my class to Word and I'll attach it.
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  13. #13
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Textbox Exit Event (MSForms 2.0)

    Here's a sample in Word. The class allows you to create an array of "spin-textboxes." I think that it is very nice, but I would like to inform the user immediately if he enters an out-of-range number directly into a textbox. To do that I need an Exit event. Have fun! --Sam
    Attached Files Attached Files
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  14. #14
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Textbox Exit Event (MSForms 2.0)

    Ok, how's this:
    Attached Images Attached Images
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  15. #15
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Textbox Exit Event (MSForms 2.0)

    But then you have to write the same event code (ie call a common subroutine) for each control. That's fine for just a few controls, but gets really ugly for a bunch. That's the beauty of putting them into a class module: you can have an array or collections of controls with only one event routine similar to what you can do in VB. For example, on my form you cannot enter letters in the textboxes, just numbers. This is done with a single keyDown event in the class module. But, unfortunately, the Exit event is not exposed in the class module. Does that start to make sense? --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

Page 1 of 2 12 LastLast

Posting Permissions

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