Hi ...
In VB 6.0 if we want to create a variable that can accept any kind of data..then we declare the variable as "variant" datatype.
For ex: Dim x1
so that x1 can accept any data whether its a string,decimal,integer etc
Similarly,can anyone plz suggest me how to create a such variable in c#.net
(i.e. variable with variant datatype)
Thank you so much in Advance
siri
7 5899
Hi ...
In VB 6.0 if we want to create a variable that can accept any kind of data..then we declare the variable as "variant" datatype.
For ex: Dim x1
so that x1 can accept any data whether its a string,decimal,integer etc
Similarly,can anyone plz suggest me how to create a such variable in c#.net
(i.e. variable with variant datatype)
Thank you so much in Advance
siri
In C# everything is an object(even methods).
That means you can store anything in a variable of type Object.
In C# everything is an object(even methods).
That means you can store anything in a variable of type Object.
Therefore I would assume it's the same in VB.NET...I usually use "object" if I need to store an item of unknown data type. In fact, I always did the same in VB 6.0; I've only ever used the variant datatype for arrays.
Therefore I would assume it's the same in VB.NET...I usually use "object" if I need to store an item of unknown data type. In fact, I always did the same in VB 6.0; I've only ever used the variant datatype for arrays.
I've never used VB.NET (which I hate even more passonately than C#) so there.
@OP. Please do not flood the forum with multiple threads on the same topic. It's against the guidelines. I've already deleted two other threads on the same topic. I hope I won't have to do it again.
If you tried any code then post it and tell us the error you got. Don't just say "it didn't work".
I believe for arrays, you should use one of the System.Collections objects for dynamic usage, or "Array" for non-dynamic usage.
Otherwise Object will work just fine, provided you know what you're doing.
I believe for arrays, you should use one of the System.Collections objects for dynamic usage, or "Array" for non-dynamic usage.
Otherwise Object will work just fine, provided you know what you're doing.
Yeah, these days you do, I was referring back to VB6/VBA. Now it's been replaced with System.Collections, System.Collections.Generics, System.Array, System.String(), System.Byte() etc...I don't think there's really a need for the Variant type any more. I certainly can't think of a direct requirement for it other than backwards compatibility. I haven't used it in quite a while.
Yeah, these days you do, I was referring back to VB6/VBA. Now it's been replaced with System.Collections, System.Collections.Generics, System.Array, System.String(), System.Byte() etc...I don't think there's really a need for the Variant type any more. I certainly can't think of a direct requirement for it other than backwards compatibility. I haven't used it in quite a while.
The variant type has been banished in VB.NET.
It does not port well with other languages and made VB slower as it would have to determine which type to cast to all the time.
It's all voodoo I tell you ...
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Matt Smith |
last post by:
Hi, all.
Just a quick question, when setting a COM process to read a value from
a pre-defined register index, I think, I have to change the variable
that the value will be returned to (as I have...
|
by: Annie |
last post by:
I am trying to call a COM object which expects a variant datatype to
be passed in to the COM API object. However, I get "<COMObject
<unknown>>" and the program fails.
Below is my code in Python,...
|
by: MLH |
last post by:
If I choose to dim MyDate as Date or MyDate as Variant,
what is the most significant difference between the two
choices?
|
by: MLH |
last post by:
A97 HELP shows the proper syntax for using Nz as
Nz(variant)
I'm wondering what to expect from potential past
misuse I've made. For example, consider the following...
Private Sub...
|
by: Jon Davis |
last post by:
Hi guys!
Just wanted to let you all know that I created a Variant structure, inspired by the old VB6 days. This is written in C#, but you can build a CLR/.NET class library assembly and reference...
|
by: SivaprakashShanmugam |
last post by:
Hi,
I have an Activex control with VARIANT* parameter type. I want to pass an
Array from CSharp to that parameter how can i pass it.
|
by: Heike |
last post by:
Hello everybody,
I have a Problem with C Sharp. I have to use external functions in DLLs.
This Functions are written in Visual C++ 6 like this:
int (__stdcall *GetGlobalValue) (VARIANT Appl,...
|
by: G Gerard |
last post by:
Hello
If Variant type is the data type that contains any kind of data type is
there a reason why one would not always use Variant when declaring
variables?
Thanks
G Gerard
|
by: =?Utf-8?B?cmtibmFpcg==?= |
last post by:
How can I define type variant in c#?
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
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
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |