Real Software Forumshttp://forums.realsoftware.com/ type of variablehttp://forums.realsoftware.com/viewtopic.php?f=21&t=41832 Page 1 of 1

 Author: carmine [ Wed Dec 14, 2011 11:28 am ] Post subject: type of variable Hi everyone,How I can to define the variable's type ?Exist a command or function to do this ?For example, for a integer variable, I would:type(a) -> integerthanks.bye.

 Author: Jason_Adams [ Wed Dec 14, 2011 11:54 am ] Post subject: Re: type of variable I highly recommend reading the User's Guide.But the syntax for a variable is: Dim VarName As VarTypeFor example:`Dim MyInt As IntegerDim Name As StringDim Choice As Boolean`Hope this helps.

 Author: carmine [ Wed Dec 14, 2011 12:19 pm ] Post subject: Re: type of variable Jason_Adams wrote:I highly recommend reading the User's Guide.But the syntax for a variable is: Dim VarName As VarTypeFor example:`Dim MyInt As IntegerDim Name As StringDim Choice As Boolean`Hope this helps. ok.If I have a array of number, but I dont know if they are integer or double, how I can to do ?

 Author: Jason_Adams [ Wed Dec 14, 2011 12:23 pm ] Post subject: Re: type of variable Go with Double, as a Double can handle and Integer, but an Integer cannot handle a Double:`Dim Db As DoubleDim Int As IntegerDb = 20 // WorksDb = 20.01 // WorksInt = 20 // WorksInt = 20.01 // Breaks`

 Author: carmine [ Thu Dec 15, 2011 5:12 am ] Post subject: Re: type of variable Jason_Adams wrote:Go with Double, as a Double can handle and Integer, but an Integer cannot handle a Double:`Dim Db As DoubleDim Int As IntegerDb = 20 // WorksDb = 20.01 // WorksInt = 20 // WorksInt = 20.01 // Breaks`No. I resolved.If I have a variant type, by "vartype" command I can know the variable's type.For example:vartype(Double) -> 5vartype(array of Boolean) -> 4107bye

 Author: NaNdummy [ Mon Apr 23, 2012 6:09 am ] Post subject: Re: type of variable if myvariable isa integer thenmycode 1elsemycode 2end ifIf you want something like getting it in a string, also I search a solution for that (eg. catching a runtime exception with the exception statement and displaying its name in a msgbox).

 Author: arthofer [ Mon Apr 23, 2012 7:17 am ] Post subject: Re: type of variable You would need a small function:`Function VarType(val as Variant) As Integer Return val.TypeEnd Function`This returns you a TypeCode for the passed Variable.Quoted from the Language reference:Quote:Variant.TypeFrom Real Software DocumentationMethodVariant.Type ( ) As IntegerReturns an Integer, indicating the data type of the Variant. The values of each data type are given in the table in the Notes section of the VarType function. NotesIf the Variant is an array, then Type returns TypeArray logically OR'ed with the array element type. You can get the element type by calling ArrayElementType. An array of Dates will be designated as an array of Objects. If the Variant is not Nil, it provides the same functionality as the VarType global function. You can use the Variant class constants instead of the integer values to determine the data type. The names are listed as Class Constants on the Variant page.

 Page 1 of 1 All times are UTC - 5 hours Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Grouphttp://www.phpbb.com/