Previous Thread
Next Thread
Print Thread
Rate Thread
#17546 10/17/03 08:06 AM
Joined: Jun 2002
Posts: 62
Junior Member
Junior Member
Joined: Jun 2002
Posts: 62
hey all,

my first VB assignment at uni works fine except for one thing. When the program starts it runs until it gets to SetFocus and then gives me a Run time error '5' an invalid procedure call or argument.

Code
 Private Sub Form_Load()
    optBackColour1.Value = True
    optTextColour1.Value = True
    optFont1.Value = True
    optPointSize1.Value = True
    txtStyles.SetFocus
End Sub

Private Sub optBackColour1_Click()
    txtStyles.BackColor = &HFFFFFF
    txtStyles.SetFocus
End Sub 
when it starts it reads the Form_Load code and skips to the optBackColour1_Click sub be qives me the error when it gets to txtStyles.SetFocus

any help will be appreciated.....


"Mrs. Jones, I'm sorry to inform you, but we've run the tests, and it appears that you have XP. Now don't cry - it's bad, but it's not a death sentence. Modern science has advanced in recent years, and it's now possible to live a reasonably happy life with XP. And there's a survivor's group that you'll want to meet as well."
Sponsored Links
▼ Sponsored Links ▼ ▲ Sponsored Links ▲
#17547 10/17/03 09:18 PM
Joined: Mar 2002
Posts: 1,273
DollarDNS Owner
DollarDNS Owner
Joined: Mar 2002
Posts: 1,273
The moment I saw the title "SetFocus" I just knew what the question would be. There's only one error I've ever gotten with SetFocus and that is when you're trying to give a control Focus when it isn't visible. The Form_Load event fires before the Form_Activate event and therefor is not visible at the time.


Domain Registration, Hosting, Management
http://www.dollardns.net
#17548 10/18/03 05:19 PM
Joined: Mar 2002
Posts: 599
UGN's Resident Homo
UGN's Resident Homo
Joined: Mar 2002
Posts: 599
you can put in form1.show before the setfocus, that should fix it


"It's better to burn out, than to fade away."
#17549 10/18/03 08:40 PM
Joined: Jun 2002
Posts: 62
Junior Member
Junior Member
Joined: Jun 2002
Posts: 62
thanx guys for your help. it was bugging me beause i just couldn't see what was wrong


"Mrs. Jones, I'm sorry to inform you, but we've run the tests, and it appears that you have XP. Now don't cry - it's bad, but it's not a death sentence. Modern science has advanced in recent years, and it's now possible to live a reasonably happy life with XP. And there's a survivor's group that you'll want to meet as well."

Link Copied to Clipboard
Member Spotlight
None yet
Forum Statistics
Forums41
Topics33,840
Posts68,858
Members2,176
Most Online3,253
Jan 13th, 2020
Latest Postings
Top Posters
UGN Security 41,392
Gremelin 7,203
§intå× 3,255
SilentRage 1,273
Ice 1,146
pergesu 1,136
Infinite 1,041
jonconley 955
Girlie 908
unreal 860
Top Likes Received
Ghost 2
Dartur 1
Cyrez 1
Girlie 1
unreal 1
Powered by UBB.threads™ PHP Forum Software 8.0.0