473,320 Members | 2,088 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,320 software developers and data experts.

Why we give a function data type?

vb.
Why we give a function data type?
when we declare a function we gave a name and datatype for that function what for?
if i make a parameter i declare it and give it a datatype and if i use variabels in function i daclare it too so what the use of datatype function??
Nov 20 '05 #1
6 1586
The Basic Defintion of a funtion is a method that returns data. They is why
you give them a type. Usally you process some information in the Function
and the function returns it's result.

"vb." <an*******@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.com...
Why we give a function data type?
when we declare a function we gave a name and datatype for that function what for? if i make a parameter i declare it and give it a datatype and if i use

variabels in function i daclare it too so what the use of datatype
function??
Nov 20 '05 #2

Seams you are new in developping with VB and coming from C++......

In VB there are SUB's and Functions in C there are only functions.

If your Function don't has a Returnvalue then you can use "SUB " instead of
a "FUNCTION"

A Function only makes sense if it returns something......

"vb." <an*******@discussions.microsoft.com> schrieb im Newsbeitrag
news:0D**********************************@microsof t.com...
Why we give a function data type?
when we declare a function we gave a name and datatype for that function what for? if i make a parameter i declare it and give it a datatype and if i use

variabels in function i daclare it too so what the use of datatype
function??
Nov 20 '05 #3
Sometimes you need to return a new reference to an object. Or return a
reference to a new object.

Regards - OHM

vb. wrote:
Why we give a function data type?
when we declare a function we gave a name and datatype for that
function what for?
if i make a parameter i declare it and give it a datatype and if i
use variabels in function i daclare it too so what the use of
datatype function??


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #4
"vb." <an*******@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.com...
Why we give a function data type?
when we declare a function we gave a name and datatype for that function what for? if i make a parameter i declare it and give it a datatype and if i use

variabels in function i daclare it too so what the use of datatype
function??

To prevent that you accidentally returning the wrong datatype (use 'Object'
if you need a Function that can return multiple datatypes)?

When you give a function in a Class a DataType, Code outside the Class that
calls the Function, can see What Datatype to expect in return from that
Function.

I guess that the Compiler could look at the code inside your Function and
see what DataType the Variable that returns a value got, but there might be
several
return-statements in a function. Witch one would be the correct one, and it
would require the Compiler to scan through you code ever time you made a
referance to a function, making it very inefficient and slow.


Nov 20 '05 #5
Cor
Hi VB

The function is no datatype, you tell what you want to give back.

But while I am writting this down I think also that it is a little bit old
fashion because that you can see in the function.

Something from the old teletype time and before to see if what is typed in
is correct.

Cor

Nov 20 '05 #6
* =?Utf-8?B?dmIu?= <an*******@discussions.microsoft.com> scripsit:
Why we give a function data type?
The return value? To return a value in a specific type. For example a
string or an integer.
when we declare a function we gave a name and datatype for that
function what for?
You have a name too. And a "function" too. What for?

The name is used for identification within your code, the datatype is
used to tell the user/code which datatype the returned value has.
if i make a parameter i declare it and give it a datatype and if i use
variabels in function i daclare it too so what the use of datatype
function??


....

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #7

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

Similar topics

2
by: Fernando Rodriguez | last post by:
Hi, I need to traverse the methods defined in a class and its superclasses. This is the code I'm using: # An instance of class B should be able to check all the methods defined in B #and A,...
1
by: Az Tech | last post by:
Hi people, (Sorry for the somewhat long post). I request some of the people on this group who have good experience using object-orientation in the field, to please give some good ideas for...
6
by: komal | last post by:
hi all basically my problem is i have to write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function...
5
by: Try Kret | last post by:
Hello ! I was wondering how to create a function that can be applied to all type of variables? If we use for example, sortList(void *obj), we can not do the comparison of 2 strcut. ...
28
by: Yuri CHUANG | last post by:
"No newline at the end of your output" is really a problem? I've never learned that before. So I desire to know some tips about writting a program perfectly.Can anyone give me some tips which are...
3
by: Beta What | last post by:
Hello, I have a question about casting a function pointer. Say I want to make a generic module (say some ADT implementation) that requires a function pointer from the 'actual/other modules'...
3
by: markww | last post by:
Hi, I have a wrapper around some 3rd party database library function. The pseudo code looks like the following - it is meant to open a table in a database, extract values from a table, then copy...
9
by: manstey | last post by:
Hi, My question probably reflects my misunderstanding of python objects, but I would still like to know the answer. The question is, is it possible for an instnace to have a value (say a...
10
by: alij | last post by:
Hi, I have just started learning C and am working on pointers but am having difficulty with the following: If i have a struct, that includes a pointer to char (in my case, i've named it...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.