|
-
Mar 3rd, 2001, 02:46 AM
#1
Thread Starter
Lively Member
what's wrong with this code?
private sub test(ctl as textbox)
ctl.text="blah blah"
end sub
private sub txttest_gotfocus()
test(txttest)
end sub
in this code i want to write blah blah when the textbox
get focus, but when the control does get focus in run
time, an error message pops up saying "type mismatch"
(i tried to write "ctl as control", but it didnt work as well)
-
Mar 3rd, 2001, 03:05 AM
#2
Fanatic Member
Why not putting your text immediately in the gotfocus.
private sub text1_GotFocus()
text1.text = "blablabla"
end sub
greetz
Ray
-
Mar 3rd, 2001, 03:21 AM
#3
Well ...
Originally posted by murphy
what's wrong with this code?
private sub test(ctl as textbox)
ctl.text="blah blah"
end sub
private sub txttest_gotfocus()
test(txttest)
end sub
in this code i want to write blah blah when the textbox
get focus, but when the control does get focus in run
time, an error message pops up saying "type mismatch"
(i tried to write "ctl as control", but it didnt work as well)
As for the task of displaying a fixed caption when your textbox receives focus, marex has answered it. And as for why your code is not working, remove the parenthesis around txttest and re-write the code as:
Code:
private sub txttest_gotfocus()
test txttest
end sub
.
-
Mar 3rd, 2001, 03:39 AM
#4
Thread Starter
Lively Member
gr8, it worked...but
what is the diferrence between putting the params
inside a parenthesis or without ?
-
Mar 3rd, 2001, 04:54 AM
#5
Hyperactive Member
Just a guess
My guess is you need the paranthesis only when you are assigning it to a variable.
===========================
Kourosh Gonabadi
VB Programmer 
C++ Newbie 
Graphic Designer
===========================
-
Mar 3rd, 2001, 05:01 AM
#6
Fanatic Member
or if you are passing a variable and not an object.?!?.!
-
Mar 3rd, 2001, 08:28 PM
#7
Well ...
Parentheses are required only for a function which returns a value. Since procedures don't return a value you need not put the parameters in parentheses.
Just for fun's sake, try the following code. I have not tested it myself, but I guess it will work:
Code:
Private Sub txttest_GotFocus()
Call Test(txttest)
End Sub
I guess if you omit the parentheses now, you will get an error. Because this time you are using the Call method to execute the procedure.
As I said, it may not be the case, since I have never tried it myself.
.
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
|