• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4314
  • Last Modified:

SetFocus error with VB6 and XP

I have a form with a TextBox named "txtDateFin".  When KeyPress = Enter (13), the focus go to the ComboBox named "cmbRapport".  In Windows 2000, it's ok.  In Windows XP, i receive intermittent error "Error 5 Invalid procedure call or argument" on line : cmbRapport.SetFocus


This my function:

Private Sub txtDateFin_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        KeyAscii = 0
        If txtDateFin.Text = "" Then
            If IsDate(txtDateFin.Text) = False Then
                pnlNonTher.Panels(1).Text = "Date error"
                Exit Sub
                lblRapport.Enabled = True
                cmbRapport.Enabled = True
                cmbRapport.SetFocus '??? Error 5 procedure call or argument
            End If
        End If
    End If
End Sub
1 Solution
>                cmbRapport.Enabled = True
>                cmbRapport.SetFocus

                  cmbRapport.Enabled = True
andreouelletAuthor Commented:
The cmbRapport.Refresh not working.
I add too cmbRapport.Visible = true.
The cmbRapport.Visible not working too.
Does any of these return False:
    MsgBox cmbRapport.Enabled, , "Enabled"
    MsgBox cmbRapport.Visible, , "Visible"
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

andreouelletAuthor Commented:
MsgBox cmbRapport.Enabled, , "Enabled" >> true
MsgBox cmbRapport.Visible, , "Visible" >> true

I add the line : "if cmbRapport.Enabled = True then" but problem stay.  But with the line "DoEvents" before the line "cmbRapport.SetFocus" the problem disappear?????

     lblRapport.Enabled = True
     cmbRapport.Enabled = True

     if cmbRapport.Enabled = True then 'problem stay
          DoEvents 'Problem disappear ???
          cmbRapport.SetFocus '??? Error 5 procedure call or argument
     end if
>          DoEvents 'Problem disappear ???

DoEvents allows execution of low prority tasks.

I thought cmbRapport did not finish redrawing its enabled state, when I suggested "cmbRapport.Refresh"
But it looks like there are some other tasks (maybe redrawing container of cmbRapport?)

You can delete the question, if DoEvents works for you.
andreouelletAuthor Commented:
Thanks for your help, ameda
Better "thank you" would be if you deleted the question.  I don't like B grade.
andreouelletAuthor Commented:
To ameda:

Why do you say "I don't like B grade"?

ameba complains about any non-A grade.  I think it's petty and not good for user-relations.  In this case, it appears that ameba helped you arrive at some resolution, which (by ExEx grading rules) deserves a B grade.

If you are confused or upset about ameba's comment, I suggest you report your displeasure in the ExEx community support area.

I'll try to be polite about this, but... I don't know what your issue with ameba is, but I do know that it's not your concern. If ameba has a problem with a grade, he can leave a question in CS for the Moderators, and we'll adjudicate it. If you're ever a Moderator, then it's your place, but in the meantime, please let us do our jobs.


Grading at EE is a touchy subject. It helps if you think of it like the "10-Point Must" system in boxing. You should assume an A, and then deduct depending on how much use you get from the responses. If the response leads you to the correct information, then a B might be justified, depending on how much additional work you have to do. You should almost never leave a C, but rather, give the Experts the chance to give you more information.


This question will NOT be deleted. I have no problem with your asking andreouellet why SPECIFICALLY he gave you a B and what you have to do to make it an A, but a B is a perfectly legitimate grade and the fact that you "don't like it" is not reason enough for upgrading it.

CS Moderator
The goal on grading is to assess the value given in the question, and to give it the level of quality that will entice others to visit the solution if it served you once the question has migrated to our PAQ.  People are more likely to visit a question in our PAQ that is an A level response than one which is a B level response.

Hope that helps add insight.  In addition, the points you give a question remain the same, but the points which flow to the expert are a direct result of the grade assigned.

Example:  100 points at an A grade = 400, B = 300, C=200

Moondancer - EE Moderator
Based on review and feedback from other moderators, the grade is changed.

Please see below.

E-E Moderator

How Do I Know What Grade to Give?
Although we use an A-D scale here at Experts Exchange, it works differently than, say, school grades.
If one or more Experts' proposals are accepted as answers, they should usually be given an A or B grade,
since they have taken the time to provide you with a working solution. If a possible solution is incomplete
- ask for clarification or details before accepting the answer and grading it. People should not be
given lower grades because of incorrect grammar or because you just accepted their answer or comment
to close the question. Keep in mind, your question and any follow-up comments should be focused so that
there can be a specific answer. The following is a good guideline to follow when grading:

A: The Expert(s) either provided you with a thorough answer or they provided you with a link to information
that thoroughly answered your question. An "A" can also be given to any answer that you found informative
or enlightening beyond the direct question that you asked.

B: The Expert(s) provided an acceptable solution, or a link to an acceptable solution, that you were
able to use, although you may have needed a bit more information to complete the task.

C: Because Experts' reliability are often judged by their grading records, many Experts would like the
opportunity to clarify if you have questions about their solutions. If you have given the Expert(s)
ample time to respond to your clarification posts and you have responded to each of their posts providing
requested information; or if the answers, after clarification, lack finality or do not completely address
the issue presented, then a "C" grade is an option. You also have the option here of just asking Community
Support to delete the question.

Remember, the Expert helping you today is probably going to be helping you next time you post a question.
Give them a fair chance to earn an 'Excellent!' grade and they'll provide you with some amazing support.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now