|
| 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. 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 ▲
| | | 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. | | | | 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."
| | | | 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."
| | |
Forums41 Topics33,840 Posts68,858 Members2,176 | Most Online3,253 Jan 13th, 2020 | | | |
|