|
-
Feb 12th, 2003, 07:34 PM
#1
Thread Starter
Frenzied Member
Set Focus to Text Box on another form?
SetFocus from the code module of another form?
The code below worked a few times during the development of my new application, which is far from finished. Now the compile results in an error message (Invalid procedure call or argument) for the first of the two bold lines below.
VB Code:
Private Sub cmdClear_Click()
Call ArrayResetter
SquareResetRequired = True
ArrayChanged = False
[B]frmSquare.txtCell(0).SetFocus[/B]
End Sub
Private Sub cmdFill_Click()
[B]. . . .[/B] ‘A Select Case with some Call Statements not shown here
Call SquareSummer
ArrayChanged = True
SquareResetRequired = False
[b]frmSquare.txtCell(0).SetFocus[/B]
End Sub
When I make the first bold line above into a comment, the compile works with no error messages. TxtCell is a Control Array mostly generated at Run-Time. TxtCell(0) exists at design time.
The application uses two ordinary (not Midi) forms and a code module. The above code in the code module associated with one Form (frmcontrol), which activates the other Form (frmSquare) by setting focus to a Text Box on the second form. When the first bold line is changed to a comment, the code compiles, and the second form is activated by (I assume) the action of the second bold line.
I have changed the order of the two subroutines and the same code causes the error message. I have used copy/paste to make certain that the two statements are identical. I am pretty sure the code complied a few times before the trouble started. I forget which code was added just prior to the problem. The code added was in other procedures, so it is hard to imagine that it had any effect.
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
-
Feb 12th, 2003, 07:51 PM
#2
If the object is not visible, or not enabled, then it can't receive focus. That's the only thing I can think of.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Feb 13th, 2003, 05:49 PM
#3
Thread Starter
Frenzied Member
CrptcBlade: This is an error produced by Start with full compile, prior to actually using the application. The code is being compiled, not executed. It has to be scope of variables, CPU tic, VB Fubar, Windows 98 glitch, et cetera.
If the message occurred for both Subroutines, I would assume that I was not allowed to Set Focus to a Text box on another form.
When I turn the line of code into a comment for one subroutine, the applications compiles and runs. When application is run, focus is set to one form from the other with no problem. It acts as I would expect.
Both of the subroutines with the problem line of code are Command Button Click events on the same form.
If somebody described this anomaly to me, I would not believe it happened that way. I seems so weird.
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|