Results 1 to 6 of 6

Thread: Choices (VB6)

  1. #1
    Lounger
    Join Date
    Jun 2002
    Location
    Toronto, Ontario
    Posts
    45
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Choices (VB6)

    Here's the scoop.

    I have an opening form with three choices, the user either clicks on
    a checkbox, enters a docket number or enters an invoice number. Only
    one selection is allowed, but just in case "The User" decides to enter
    data into multiple areas, I decided to restrict that so that they are
    only allowed to click the checkbox or enter data in one of the textboxes.

    A docket number has five characters, one alpha and four numeric.
    An invoice has 6 numeric.
    The checkbox is OK, you only click once however in the textbox the code
    executes each time a character is entered. This is only noticeable if
    you step through the code.

    My questions then are these,

    Should I worry about it? After all it does run and is not noticeable to
    the user.
    If I should worry about it, how do I change it so that the code only
    executes for the first occurence of change?

    My code is below for each choice.

    Private Sub txtDcktNum_Change()
    dlgDktOrInv.chkOpenDocket.Enabled = False
    chkOpenDocket = 0
    dlgDktOrInv.txtInvNum.Enabled = False
    End Sub

    Private Sub txtInvNum_Change()
    dlgDktOrInv.chkOpenDocket.Enabled = False
    chkOpenDocket = 0
    dlgDktOrInv.txtDcktNum.Enabled = False
    End Sub

    Private Sub chkOpenDocket_Click()
    dlgDktOrInv.txtDcktNum.Enabled = False
    dlgDktOrInv.txtInvNum.Enabled = False
    End Sub

    Input and/or instruction/suggestions appreciated.

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Choices (VB6)

    You can't keep change from firing with every keystroke, but you could set a flag either at the form level or using a static variable in the Change event procedure to indicate that the other controls had been disabled. Only run the disable code if the flag is false.
    Charlotte

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Choices (VB6)

    I wouldn't worry too much about the overhead of the change event, I've never seen it consuming vast resources.

    You could allow the user to clear one of the textboxes and then use a different control by modifying your change event to...
    <pre>Private Sub txtInvNum_Change()
    If txtlnfNum.Text = "" Then
    dlgDktOrInv.chkOpenDocket.Enabled = True
    dlgDktOrInv.txtDcktNum.Enabled = True
    Else
    dlgDktOrInv.chkOpenDocket.Enabled = False
    chkOpenDocket = 0
    dlgDktOrInv.txtDcktNum.Enabled = False
    End If
    End Sub
    </pre>


    This would enable them to change their mind after starting to enter an invoice number.

    StuartR

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Choices (VB6)

    Avoid the Change event in most cases.
    Look at the AfterUpdate and BeforeUpdate events.

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Choices (VB6)

    My version of VB6 doesn't have a BeforeUpdate event, Howard, only a Validate event.
    Charlotte

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Choices (VB6)

    My mind was in VBA mode, not VB mode.

Posting Permissions

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