cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Dim Array problem in VB

Raiko
17-Peridot

Dim Array problem in VB

Hello folks,

I have a strange problem: within a script (see attached file) the VB Editor doesn't accept a command line such as:

Dim Metric(2) as Integer

Dim Metric(2) works however.

Strange isn't it? I'd like to define the type of data because otherwise it might end up as variant which is slow.

Any suggestions?

Raiko
3 REPLIES 3
StuartBruff
23-Emerald III
(To:Raiko)

On 8/14/2009 7:24:17 AM, raiko01 wrote:
== I have a strange problem: within a script (see attached file) the VB Editor doesn't accept a command line such as:
== Dim Metric(2) as Integer
== Dim Metric(2) works however.
== Strange isn't it? I'd like to define the type of data because otherwise it might end up as variant which is slow.

I think VBScript only has one data type, Variant

see http://msdn.microsoft.com/en-us/library/9e7a57cf(VS.85).aspx

However, it will store the data in an appropriate form within the variant (see below, which is a copy of the text on the above link)

Stuart

VBScript Data Types

VBScript has only one data type called a Variant. A Variant is a special kind of data type that can contain different kinds of information, depending on how it is used. Because Variant is the only data type in VBScript, it is also the data type returned by all functions in VBScript.

At its simplest, a Variant can contain either numeric or string information. A Variant behaves as a number when you use it in a numeric context and as a string when you use it in a string context. That is, if you are working with data that looks like numbers, VBScript assumes that it is numbers and does what is most appropriate for numbers. Similarly, if you're working with data that can only be string data, VBScript treats it as string data. You can always make numbers behave as strings by enclosing them in quotation marks (" ").

Variant Subtypes
Beyond the simple numeric or string classifications, a Variant can make further distinctions about the specific nature of numeric information. For example, you can have numeric information that represents a date or a time. When used with other date or time data, the result is always expressed as a date or a time. You can also have a rich variety of numeric information ranging in size from Boolean values to huge floating-point numbers. These different categories of information that can be contained in a Variant are called subtypes. Most of the time, you can just put the kind of data you want in a Variant, and the Variant behaves in a way that is most appropriate for the data it contains.
Raiko
17-Peridot
(To:StuartBruff)

Hello Stuart,

thank you for this. Makes life easier albeit MathCad slower

Raiko

"Makes life easier albeit MathCad slower"
___________________________

Really hard to understand what you are trying to do, specially why you need a VB script. There is no project in there ... Dim(,),,, Dim what ?



The other point is about the warning message. Passing a scripted component from non-expert, puts the reader at risk. Personally, I open only Richard script. v for a single column vector, xy for a two column array, xyz for a 3 column array ...

jmG

Announcements

Top Tags