Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4289
  • 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

Thanks

This my function:

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

try:
                  cmbRapport.Enabled = True
                  cmbRapport.Refresh
                  cmbRapport.SetFocus
0
 
andreouelletAuthor Commented:
The cmbRapport.Refresh not working.
I add too cmbRapport.Visible = true.
The cmbRapport.Visible not working too.
0
 
amebaCommented:
Does any of these return False:
    MsgBox cmbRapport.Enabled, , "Enabled"
    MsgBox cmbRapport.Visible, , "Visible"
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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
'???????????????
0
 
amebaCommented:
>          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.
0
 
andreouelletAuthor Commented:
Thanks for your help, ameda
0
 
amebaCommented:
Better "thank you" would be if you deleted the question.  I don't like B grade.
0
 
andreouelletAuthor Commented:
To ameda:

Why do you say "I don't like B grade"?
0
 
aikimarkCommented:
andreouellet,

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.
0
 
NetminderCommented:
aikimark,

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.

andreouellet,

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.

ameba,

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.

Netminder
CS Moderator
0
 
MoondancerCommented:
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
0
 
Computer101Commented:
Based on review and feedback from other moderators, the grade is changed.

Please see below.

Computer101
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.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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