Question:
disadvantage of Variant data type in Visual Basic?
Kalvin
2012-09-24 23:25:31 UTC
disadvantage of Variant data type in Visual Basic
Four answers:
Ben B
2012-09-24 23:36:05 UTC
Most of the time there may be none, except barely noticeable increase in memory usage (unless you're using them alot). Most of the time, it will just be more convenient to be explicit with the data type if you know what it will be before run time. Specifically, it will depend on the case. If you want some more information, ill google that for you: http://lmgtfy.com/?q=why+not+use+variant+type
2016-08-02 07:21:44 UTC
First of all by no means ever use a variant data kind, its giant sluggish and quite unhealthy. Truly a variant allows for all types of knowledge, be they integers, doubles or strings. They're a "fail risk-free" form of variable type as they are going to in most cases under no circumstances by way of an error for being the fallacious form (as they're all conventional forms.) however considering that of this they take in extra space (around 12+ bytes per variable, more if they maintain a string) and are slow VB will ought to assess what form of data they're preserving.
Gardner
2012-09-25 01:53:52 UTC
Using Variant vs a strict data type removes the ability of the IDE to detect code errors as you key in your code. Example:



Dim myInt As Variant

myInt = "A"



This is valid, however if you try to do any math operations on myInt while it contains "A" then you'll get a run time error. If you define it like this:



Dim myInt As Integer

myInt = "A"



The IDE will flag the error right then and let you know you tried to assign an invalid type to the variable.
2012-09-24 23:28:59 UTC
Hi Visual basic is a software program, it will contain variables as part of a program which is normal.

all programming languages contain variables for working out solutions to problems.

the algorithm has to have something to work with, other wise what is the point of a program.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...