SetFocus causing Run time error

443 Views Asked by At

I am getting:
Run-time error '5':
Invalid procedure call or argument

this seems to happen when Text(1).SetFocus is called.

However, I dont see this run time error for all the cases where I have used SetFocus. Just 2-3 places it is causing this error.

Text(1).SelStart = 3
Text(1).SelLength = 1
Text(1).SetFocus

I tried:

Text(1).Enabled = True  
Text(1).Visible = True  

just above .SelStart, but it didn't fix the issue.

UPDATE:

If I run the application using debugger/VB5 IDE, then i dont see any error. But when I create the exe and run then I see this error.

UPDATE: Even though I was doing
Text(1).Enabled = True
Text(1).Visible = True
it didnt work, but when I did

If Text(1).Enabled And Text(1).Visible Then  
    Text(1).SetFocus
End If   

It didnt show run time error. Not sure what is going on.

0

There are 0 best solutions below