473,387 Members | 1,542 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,387 software developers and data experts.

Variable function return type

Hi

I have a function that needs to return value from some column in a table.
The column type is not known in advance. Is it possible for function to
return a value whose type would be determined at runtime? If so, how?

Thanks

Regards
Dec 1 '07 #1
6 1603
"John" <Jo**@nospam.infovis.co.ukschrieb
Hi

I have a function that needs to return value from some column in a
table. The column type is not known in advance. Is it possible for
function to return a value whose type would be determined at
runtime? If so, how?
The type is Object, so the return type is Object, too.
Armin
Dec 1 '07 #2
John,
>
The column type is not known in advance.
Just curious, how did you create that? In my idea is that hard to do in
..Net.

Cor

Dec 1 '07 #3
"John" <Jo**@nospam.infovis.co.ukwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Hi

I have a function that needs to return value from some column in a table.
The column type is not known in advance. Is it possible for function to
return a value whose type would be determined at runtime? If so, how?

Thanks

Regards
Have your function return be of type "Object". You will need to use "Is
<type>" to determine the actual return type and then use CType to coerce it
to the correct actual type before you can use the result.

Mike Ober.
Dec 1 '07 #4
"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:29**********************************@microsof t.com...
John,
>>
The column type is not known in advance.

Just curious, how did you create that? In my idea is that hard to do in
.Net.

Cor
This is easy to do, even with Option Strict On. The MS Office interop
classes are full of functions that return "Object" instead of the actual
types.

Mike Ober.
Dec 1 '07 #5
Michael,

To me you write that it has no type and then you tell that you can get a
type, what is the truth, has it a type or does it have no type?

I am interested in a var without a type, that is where I am curious about.

Cor

Dec 1 '07 #6
"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:DD**********************************@microsof t.com...
Michael,

To me you write that it has no type and then you tell that you can get a
type, what is the truth, has it a type or does it have no type?

I am interested in a var without a type, that is where I am curious about.

Cor
I've never heard of a variable without a type other than in typeless
languages. You misunderstood my comments - if you need to return multiple
types from a function, return type "Object". The calling code must then
cast it to the correct type before anything can be done with it. Also, as I
stated, the MS Office Interop assemblies are full of functions that return
"Object" and not the actual type. I assume that this is because the COM
world is very type limited, and the MS Office Interop assemblies must
ultimately call COM interfaces.

Mike.
Dec 2 '07 #7

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

Similar topics

2
by: Suzanne Vogel | last post by:
'stdarg.h' defines the 'va_arg' type to use in passing variable numbers of parameters to functions. The example of its use given in the Dinkumware documentation *seems* to imply that the 'va_arg'...
134
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
9
by: Stefan Mueller | last post by:
I'd like to set a variable called 'FocusIsOn' if a button got the focus. Because my button is dynamically created I do it like xelement = document.createElement("input") xelement.type = "button"...
14
by: sathya_me | last post by:
Dear clc, I have a variable void *a; Since variable "a" can be assigned (point to) any type and also any type can be assigned to "a" (i.e means "a" = any typed variable; any typed variable =...
11
by: JohnR | last post by:
I'm trying to find a way to create a variable of a given type at runtime where I won't know the type until it actually executes. For example, dim x as object = "hi" x is declared as an object...
23
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
20
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt =...
25
by: Sourav | last post by:
Suppose I have a code like this, #include <stdio.h> int *p; void foo(int); int main(void){ foo(3); printf("%p %d\n",p,*p);
2
by: Jess | last post by:
Hello, I understand that if a function "f" has a local variable "a", and after it returns, "a" vanishes. If "f" returns "a" as a result, then I noticed the following: 1. if the return type is...
1
by: faultykid | last post by:
I would like to store a variable then call it back later. I have a variable on line 198 www = ''+this._ad.clickUrl+''; and on line 321 i try document.write(www);
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.