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

HOWTO: same function name, different return types

Hi, how can I do this (I don't really want to do this but what I do
want the same function name but have different return types and the
compiler keeps saying "public function .... they differ only by return
types")?

Public Function test() As Integer
Return 1
End Function

Public Function test() As Single
Return 1
End Function

Thank you
Peter
Nov 20 '05 #1
10 2831

Public Function test(x as Integer) As Integer
Return 1
End Function

Public Function test(x as Single) As Single
Return 1
End Function

Peter wrote:
Hi, how can I do this (I don't really want to do this but what I do
want the same function name but have different return types and the
compiler keeps saying "public function .... they differ only by return
types")?

Public Function test() As Integer
Return 1
End Function

Public Function test() As Single
Return 1
End Function

Thank you
Peter

Nov 20 '05 #2

Public Function test(x as Integer) As Integer
Return 1
End Function

Public Function test(x as Single) As Single
Return 1
End Function

Peter wrote:
Hi, how can I do this (I don't really want to do this but what I do
want the same function name but have different return types and the
compiler keeps saying "public function .... they differ only by return
types")?

Public Function test() As Integer
Return 1
End Function

Public Function test() As Single
Return 1
End Function

Thank you
Peter

Nov 20 '05 #3
Thanks but my functions don't accept any arguments,ie public function test()
as ....


"yEaH rIgHt" <no******@haha.com> wrote in message
news:10*************@corp.supernews.com...

Public Function test(x as Integer) As Integer
Return 1
End Function

Public Function test(x as Single) As Single
Return 1
End Function

Peter wrote:
Hi, how can I do this (I don't really want to do this but what I do
want the same function name but have different return types and the
compiler keeps saying "public function .... they differ only by return
types")?

Public Function test() As Integer
Return 1
End Function

Public Function test() As Single
Return 1
End Function

Thank you
Peter

Nov 20 '05 #4
Thanks but my functions don't accept any arguments,ie public function test()
as ....


"yEaH rIgHt" <no******@haha.com> wrote in message
news:10*************@corp.supernews.com...

Public Function test(x as Integer) As Integer
Return 1
End Function

Public Function test(x as Single) As Single
Return 1
End Function

Peter wrote:
Hi, how can I do this (I don't really want to do this but what I do
want the same function name but have different return types and the
compiler keeps saying "public function .... they differ only by return
types")?

Public Function test() As Integer
Return 1
End Function

Public Function test() As Single
Return 1
End Function

Thank you
Peter

Nov 20 '05 #5

Just because you have arguments doesn't mean you have to use them in
your function.

Or you can try this:

Public Function test() As Object
Return 1
End Function

Now you can return anything.

Peter Ignarson wrote:
Thanks but my functions don't accept any arguments,ie public function test()
as ....


"yEaH rIgHt" <no******@haha.com> wrote in message
news:10*************@corp.supernews.com...


Public Function test(x as Integer) As Integer
Return 1
End Function

Public Function test(x as Single) As Single
Return 1
End Function

Peter wrote:
Hi, how can I do this (I don't really want to do this but what I do
want the same function name but have different return types and the
compiler keeps saying "public function .... they differ only by return
types")?

Public Function test() As Integer
Return 1
End Function

Public Function test() As Single
Return 1
End Function

Thank you
Peter


Nov 20 '05 #6

Just because you have arguments doesn't mean you have to use them in
your function.

Or you can try this:

Public Function test() As Object
Return 1
End Function

Now you can return anything.

Peter Ignarson wrote:
Thanks but my functions don't accept any arguments,ie public function test()
as ....


"yEaH rIgHt" <no******@haha.com> wrote in message
news:10*************@corp.supernews.com...


Public Function test(x as Integer) As Integer
Return 1
End Function

Public Function test(x as Single) As Single
Return 1
End Function

Peter wrote:
Hi, how can I do this (I don't really want to do this but what I do
want the same function name but have different return types and the
compiler keeps saying "public function .... they differ only by return
types")?

Public Function test() As Integer
Return 1
End Function

Public Function test() As Single
Return 1
End Function

Thank you
Peter


Nov 20 '05 #7
Hi Peter

The simple answer is you can't. One reason is ... suppose you call test()
but don't assign its return value to anything. Which version of your test
function should the compiler call?

Try this instead

Public Sub test(ByRef Value As Integer)
Value = 1
End Sub

Public Sub test(ByRef Value As Single)
Value = 1
End Sub

HTH

Charles
"Peter" <pi*******@hotmail.com> wrote in message
news:a6*************************@posting.google.co m...
Hi, how can I do this (I don't really want to do this but what I do
want the same function name but have different return types and the
compiler keeps saying "public function .... they differ only by return
types")?

Public Function test() As Integer
Return 1
End Function

Public Function test() As Single
Return 1
End Function

Thank you
Peter

Nov 20 '05 #8
Hi Peter

The simple answer is you can't. One reason is ... suppose you call test()
but don't assign its return value to anything. Which version of your test
function should the compiler call?

Try this instead

Public Sub test(ByRef Value As Integer)
Value = 1
End Sub

Public Sub test(ByRef Value As Single)
Value = 1
End Sub

HTH

Charles
"Peter" <pi*******@hotmail.com> wrote in message
news:a6*************************@posting.google.co m...
Hi, how can I do this (I don't really want to do this but what I do
want the same function name but have different return types and the
compiler keeps saying "public function .... they differ only by return
types")?

Public Function test() As Integer
Return 1
End Function

Public Function test() As Single
Return 1
End Function

Thank you
Peter

Nov 20 '05 #9
Thanks for the replies everyone.
Peter

"Peter" <pi*******@hotmail.com> wrote in message
news:a6*************************@posting.google.co m...
Hi, how can I do this (I don't really want to do this but what I do
want the same function name but have different return types and the
compiler keeps saying "public function .... they differ only by return
types")?

Public Function test() As Integer
Return 1
End Function

Public Function test() As Single
Return 1
End Function

Thank you
Peter

Nov 20 '05 #10
Thanks for the replies everyone.
Peter

"Peter" <pi*******@hotmail.com> wrote in message
news:a6*************************@posting.google.co m...
Hi, how can I do this (I don't really want to do this but what I do
want the same function name but have different return types and the
compiler keeps saying "public function .... they differ only by return
types")?

Public Function test() As Integer
Return 1
End Function

Public Function test() As Single
Return 1
End Function

Thank you
Peter

Nov 20 '05 #11

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

Similar topics

7
by: Greg Brunet | last post by:
I'm writing some routines for handling dBASE files. I've got a table (DBF file) object & field object already defined, and after opening the file, I can get the field info like this: >>>...
26
by: Adam Warner | last post by:
Hello all, I'm very new to C but I have a number of years of Common Lisp programming experience. I'm trying to figure out ways of translating higher order concepts such as closures into C. The...
2
by: Edward Diener | last post by:
In C++ an overridden virtual function in a derived class must have the exact same signature of the function which is overridden in the base class, except for the return type which may return a...
4
by: AssanKhan Ismail | last post by:
Im using an C#'s user defined private function on which i want to return more than one value (like int and string ) and from that function. please let me know in advance.. assankhan Ismail
6
by: Peter | last post by:
Hi, how can I do this (I don't really want to do this but what I do want the same function name but have different return types and the compiler keeps saying "public function .... they differ only...
5
by: Ian Bicking | last post by:
I got a puzzler for y'all. I want to allow the editing of functions in-place. I won't go into the reason (it's for HTConsole -- http://blog.ianbicking.org/introducing-htconsole.html), except that...
17
by: I.M. !Knuth | last post by:
Hi. I'm more-or-less a C newbie. I thought I had pointers under control until I started goofing around with this: ...
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...
20
by: Andrew Morton | last post by:
Is it possible to have two function declarations which take the same parameters but return different types depending on how the function is used? function f(x) as string ' return a string end...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.