Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Property Let Not working

Status
Not open for further replies.

sergiog

Programmer
Feb 17, 2003
24
MT
Hi
I have the following code in a Control I made:

Public Property Let ShowRecNo(Show As Boolean)
If Show Or Not Show Then
txtRec.Visible = Show
End If

PropertyChanged ShowRecNo

End Property

Before it goes through the line saying "txtrec.visible = show", txtrec.visible is false and show is true.
Then, when it goes through it, txtrec.visible does not chnage.

Any ideas?
thanks

sergio
 
Visibile is a Boolean option, meaning the contents are True or False. Try this:

Public Property Let ShowRecNo(Show As Boolean)
If Show Or Not Show Then
txtRec.Visible = True
End If

PropertyChanged ShowRecNo

End Property
 
Which is exactly why he's got the variable "Show As Boleean" in there.

Why do you need the If statement ( If Show Or Not Show Then ) It'll always evaluate to true ( Show is either true or false, and either condition will satisfy the If statement ), so what's the point of having it in there?

Robert
 
i have it because i thought that a user might pass any value seeing that it's a public property.

but now i removed it and it's working. cheers.

sergio.

by the way, do you have any idea how to check that a user actually passed what was intended as paramter.
for example,
I have a sub Connect(Cursortypeas CursorTypeEnum)
how would i check if the user actually passed one of the CursorTypeEnum constants without knowing the constants (maybe something like typeOf i don't know)

thanks again
 


Hi Sergiog:

If you are using
Code:
Option Explicit
and if you define a variable as anything other than Variant, then VB will do error checking. It will notify you that the parameter and argument do not agree in type.

This assumes that the error handler is still with VB. If you use the
Code:
On Error
statement to assign an error handler, then your error handler will be called when there's a mismatch between parameter and argument.

If an object is being passed, then using
Code:
If TypeOf . . . Then
becomes an option.

Cassie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top