Results 1 to 10 of 10

Thread: [RESOLVED] Message Box

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2015
    Posts
    66

    Resolved [RESOLVED] Message Box

    I am trying to program a message box on when someone clicks into a combobox. I tried this and I am getting a continuous message box. How do I only show it one time, before they select an item in the combobox?

    Code:
    Private Sub cboInteriorCarvassSpecie_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboInteriorCarcassSpecie.Click
            Dim msg = "Test Message"
    
            Dim Title = "Information"
            Dim Style = MsgBoxStyle.OkOnly
    
            MsgBox(msg, Style, Title)
    
    End Sub
    TIA

    Jeff

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: Message Box

    by "continuous" ... do you mean you get an endless loop of messageboxes? or that you keep getting it every time you click the cbo?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2015
    Posts
    66

    Re: Message Box

    Quote Originally Posted by techgnome View Post
    by "continuous" ... do you mean you get an endless loop of messageboxes? or that you keep getting it every time you click the cbo?

    -tg
    I keep getting the message box each time I click the cbo.

    JM

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: Message Box

    That is to be expected, because you have put the code in the _Click event of the combo... which fires every time you click.

    If you only want something to happen when it gets the focus, use an event dedicated to that purpose.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2015
    Posts
    66

    Re: Message Box

    Quote Originally Posted by si_the_geek View Post
    That is to be expected, because you have put the code in the _Click event of the combo... which fires every time you click.

    If you only want something to happen when it gets the focus, use an event dedicated to that purpose.
    That is the issue, what event should I use?

  6. #6
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: Message Box

    The click could work, but you need to track a flag somehow and set it when you show it, so that when you come back around, if it's set you don't show the message.

    That said... I'm not sure I like having messageboxes pop up when I click a combo box... it takes the focus away, and then I still have to click the CBo again. Doesn't feel like a good user experience to me.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Aug 2015
    Posts
    66

    Re: Message Box

    Quote Originally Posted by techgnome View Post
    The click could work, but you need to track a flag somehow and set it when you show it, so that when you come back around, if it's set you don't show the message.

    That said... I'm not sure I like having messageboxes pop up when I click a combo box... it takes the focus away, and then I still have to click the CBo again. Doesn't feel like a good user experience to me.

    -tg
    I agree on the user experience thing, I am building this for another company and the owner of the company wants a messagebox, me personally, I hate using them. Just adds extra clicks.

    This being said, is there another option for this? Before, I had the information off to the right in a label which was there from the start of the form load.

    JM

  8. #8
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: Message Box

    *shrug* I don't know the situation... only the code you posted, which appears to be sample code to illustrate the problem. The answer of how I'd implement it would depend on the situation and what it is exactly you're trying to show.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: Message Box

    Quote Originally Posted by jmyersnc View Post
    That is the issue, what event should I use?
    A quick look at the list of events for a combobox:
    https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx
    ...shows that it has GotFocus ("Occurs when the control receives focus")

  10. #10
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: Message Box

    You might want to quietly add some Ctrl+key combination on the form such that whatever solution you come up with can be turned on/off. I can totally see the person who wants this coming back with, "this is SO annoying. Make it stop!" So, you might handle keypress events at the form level and add one to turn off displaying the messagebox.
    My usual boring signature: Nothing

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