Your browser does not seem to support CSS. If images appear below, please disregard them.
It appears that you're running an Ad-Blocker. This site is monetized by Advertising and by User Donations; we ask that if you find this site helpful that you whitelist us in your Ad-Blocker, or make a Donation to help aid in operating costs.
Previous Thread
Next Thread
Print Thread
Rate This Thread
#17546 - 10/17/03 04:06 PM SetFocus  
Joined: Jun 2002
Posts: 62
UndeadBob Offline
Junior Member
UndeadBob  Offline
Junior Member

Joined: Jun 2002
Posts: 62
UK
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
#17547 - 10/18/03 05:18 AM Re: SetFocus  
Joined: Mar 2002
Posts: 1,273
SilentRage Offline
DollarDNS Owner
SilentRage  Offline
DollarDNS Owner

Joined: Mar 2002
Posts: 1,273
OH, USA
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/19/03 01:19 AM Re: SetFocus  
Joined: Mar 2002
Posts: 599
BackSlash Offline
UGN's Resident Homo
BackSlash  Offline
UGN's Resident Homo

Joined: Mar 2002
Posts: 599
TN
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/19/03 04:40 AM Re: SetFocus  
Joined: Jun 2002
Posts: 62
UndeadBob Offline
Junior Member
UndeadBob  Offline
Junior Member

Joined: Jun 2002
Posts: 62
UK
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."

Member Spotlight
Crime
Crime
SC, usa
Posts: 506
Joined: March 2002
Show All Member Profiles 
Forum Statistics
Forums45
Topics47,470
Posts82,640
Average Daily Posts7
Members2,159
Most Online1,567
Apr 25th, 2010
Latest Postings
Top Posters(All Time)
UGN Security 40,634
Gremelin 7,195
§intå× 3,255
SilentRage 1,273
Ice 1,146
pergesu 1,136
Infinite 1,041
jonconley 955
Girlie 908
unreal 860
Top Liked Users (All Time)
§intå× Likes: 1
Cold Sunn Likes: 1
Crime Likes: 1
Cyrez Likes: 1
Ghost Likes: 1
Gremelin Likes: 4
Ice Likes: 1
unreal Likes: 1
Top Liked Users (30 Days)
No Data Found
Powered by UBB.threads™ PHP Forum Software 7.6.0
(Snapshot build 20160902)