Your browser does not seem to support CSS. If images appear below, please disregard them.
toggle
February
S M T W T F S
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29
Sponsored Links
Latest Postings
Topic Options
Rate This Topic
#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."
Top
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
Top
#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."
Top
#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."
Top

Member Spotlight
Gremelin

Gremelin
Portland, OR; USA
Posts: 7,194
Joined: February 2002
Show All Member Profiles 
Forum Statistics
Forums46
Topics43,978
Posts79,152
Members2,157
Most Online1,567
Apr 25th, 2010
Top Posters(All Time)
UGN Security 37,141
Gremelin 7,194
§intå× 3,255
SilentRage 1,273
Ice 1,146
pergesu 1,136
Infinite 1,041
jonconley 955
Girlie 908
unreal 860
Newest Members
Herbert_Sherbert, codemauve, Lillysdragon1984, Brewwit, boa
2157 Registered Users
Who's Online Now
0 registered members (), 2 guests and 1 spider.
Latest News