473,385 Members | 1,461 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

New at VB

Im not sure it this is the right newsgroup but.......can someone expain to
me when the get statement fires in a property procedure.

Example
Property lastname as string
Get
LastName=mstrLastName
End Get
Set(ByVal Value as String)
mstrLastName = Value
End Set
End Property

When i remark out the assignment within the get statement, the programs
still executes

Help

Steve
Nov 20 '05 #1
14 826
* "Stephen Martinelli" <st*****@johnstontrading.com> scripsit:
Im not sure it this is the right newsgroup but.......can someone expain to
me when the get statement fires in a property procedure.

Example
Property lastname as string
Get
LastName=mstrLastName
End Get
Set(ByVal Value as String)
mstrLastName = Value
End Set
End Property

When i remark out the assignment within the get statement, the programs
still executes


The 'Property Get' will be called when getting the property's value:

\\\
Dim x As New Foo()
x.LastName = "Herfried" ' Calls Set.
Dim s As String = x.LastName ' Calls Get.
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Hi Stephen,

A Get isn't obliged to return a value. If you don't specify one, the
default for its value type will be returned.

Get
LastName = mstrLastName
End Get
is effectively the same as
Get
Dim LastName As String
LastName = mstrLastName
End Get
but you can't comment out the Dim because it's 'hidden'

Regards,
Fergus
Nov 20 '05 #3
* hi***************@gmx.at (Herfried K. Wagner [MVP]) scripsit:
Property lastname as string
Get
LastName=mstrLastName


The line above doesn't make sense. Use 'Return mstrLastName'
instead. The code above will call the 'Property Set' again.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Herfried,
The line above doesn't make sense. Use 'Return mstrLastName'
instead. I totally agree with both statements, it doesn't make sense, and you should
use the return statement!
The code above will call the 'Property Set' again. Actually it doesn't!

As Fergus explained. VB.NET has this 'feature' that allows you to use the
function/property name for the return value, instead of using Return. Which
also means you cannot declare a parameter or local variable the same name as
your function.

I find using Return to be much more obvious on what you are doing.

Hope this helps
Jay

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl... * hi***************@gmx.at (Herfried K. Wagner [MVP]) scripsit:
Property lastname as string
Get
LastName=mstrLastName


The line above doesn't make sense. Use 'Return mstrLastName'
instead. The code above will call the 'Property Set' again.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Nov 20 '05 #5
* "Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> scripsit:
The code above will call the 'Property Set' again.


Actually it doesn't!

As Fergus explained. VB.NET has this 'feature' that allows you to use the
function/property name for the return value, instead of using Return. Which
also means you cannot declare a parameter or local variable the same name as
your function.

I find using Return to be much more obvious on what you are doing.


You (and Fergus) are right (I don't see Fergus' reply for some reason).
I always used 'Return' in VB.NET, so I forgot about this "feature"
inherited from VB Classic.

;-)

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #6
Herfried,
(I don't see Fergus' reply for some reason). His response to Stephen was today about 2:52 PM CST (GMT-06:00)

Jay

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... * "Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> scripsit:
The code above will call the 'Property Set' again.


Actually it doesn't!

As Fergus explained. VB.NET has this 'feature' that allows you to use the function/property name for the return value, instead of using Return. Which also means you cannot declare a parameter or local variable the same name as your function.

I find using Return to be much more obvious on what you are doing.


You (and Fergus) are right (I don't see Fergus' reply for some reason).
I always used 'Return' in VB.NET, so I forgot about this "feature"
inherited from VB Classic.

;-)

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Nov 20 '05 #7
* "Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> scripsit:
His response to Stephen was today about 2:52 PM CST (GMT-06:00)


I can see it in OE, but not in gnus...

:-(

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #8
Any time a calling routine reference a property in a way that will read the
value from the property, the Get routine fires. So, if you do this:

MsgBox(myObj.LastName)

it will fire the Get routine (because the value is being "read"). On the
other hand, whenever you "set" a property value, the Set routine is run. So
if you do this:

myObj.LastName = "Smith"

it will fire the Set routine.

The line of code you have in the Get statement (LastName=mstrLastName) just
results in the property doing what a programmer would expect a property to
do when he/she references it (namely, return the value "stored there").
But, you don't have to do this - and furthermore, you can do anything else
you like here. For instance, you could count the number of times a property
is read (I have no idea why anyone would want to count such a thing, but
it's just an example so cut me some slack). If you did something like this
you would increment a numeric variable in the Get routine.
I hope this answers your question,

Eric
"Stephen Martinelli" <st*****@johnstontrading.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Im not sure it this is the right newsgroup but.......can someone expain to
me when the get statement fires in a property procedure.

Example
Property lastname as string
Get
LastName=mstrLastName
End Get
Set(ByVal Value as String)
mstrLastName = Value
End Set
End Property

When i remark out the assignment within the get statement, the programs
still executes

Help

Steve

Nov 20 '05 #9
Hi Herfried,

ROFL. I complain that the gnus web site is impenetrable and look at the
revenge it takes!!

Regards,
Fergus
Nov 20 '05 #10
Hi Eric,

|| For instance, you could count the number of
|| times a property is read

Yep.

|| I have no idea why anyone would want to count
|| such a thing, but it's just an example

So that you can determine out of the dozens of just-in-case properties you
have created, which ones your users are actually using.

|| so cut me some slack

Precisely! Any property found slacking gets cut.

;-)))

Regards,
Fergus
Nov 20 '05 #11
Herfried,
I use OE, not gnus.

Interesting that it won't show his post.

I wonder how many others turn up "missing".

Jay

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uL**************@TK2MSFTNGP10.phx.gbl...
* "Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> scripsit:
His response to Stephen was today about 2:52 PM CST (GMT-06:00)


I can see it in OE, but not in gnus...

:-(

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Nov 20 '05 #12
hahaha - clever. :)
Eric

"Fergus Cooney" <fi*****@post.com> wrote in message
news:Oh**************@tk2msftngp13.phx.gbl...
Hi Eric,

|| For instance, you could count the number of
|| times a property is read

Yep.

|| I have no idea why anyone would want to count
|| such a thing, but it's just an example

So that you can determine out of the dozens of just-in-case properties you have created, which ones your users are actually using.

|| so cut me some slack

Precisely! Any property found slacking gets cut.

;-)))

Regards,
Fergus

Nov 20 '05 #13
* "Fergus Cooney" <fi*****@post.com> scripsit:
ROFL. I complain that the gnus web site is impenetrable and look at the
revenge it takes!!


I think gnus is a newsreader for Linux hackers.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #14
* "Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> scripsit:
I use OE, not gnus.
I sometimes use OE and I used OE too.
Interesting that it won't show his post.


I think it's caused by misconfiguration. I will try to "fix" it.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL)...
2
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues...
3
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which...
0
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. ...
1
by: Richard Galli | last post by:
I want viewers to compare state laws on a single subject. Imagine a three-column table with a drop-down box on the top. A viewer selects a state from the list, and that state's text fills the...
4
by: Albert Ahtenberg | last post by:
Hello, I have two questions. 1. When the user presses the back button and returns to a form he filled the form is reseted. How do I leave there the values he inserted? 2. When the...
1
by: inderjit S Gabrie | last post by:
Hi all Here is the scenerio ...is it possibly to do this... i am getting valid course dates output on to a web which i have designed ....all is okay so far , look at the following web url ...
2
by: Jack | last post by:
Hi All, What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g. select x from y where z=:parameter Which in asp/jsp would be followed by some statements to bind a value...
3
by: Sandwick | last post by:
I am trying to change the size of a drawing so they are all 3x3. the script below is what i was trying to use to cut it in half ... I get errors. I can display the normal picture but not the...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.