NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
A._Baumann
Posts: 29
0 Kudos
Accepted Solution

Add Unit with VBS

Hi, does someone know how to add units using VBS? I am adding some new Channels, it will be great if I could add units with VBS directly rather than uns dialog box afterwards. Thanks!

 

Andi

Active Participant
Walter_Rick
Posts: 972
0 Kudos

Re: Add Unit with VBS

Hi Andy,

 

if you would like to add a new quantity to the UnitCatalog in DIAdem use this:

 

dim oQuantities, oMyQuantity
set oQuantities = UnitCatalog.Quantities
Set oQuantity = oQuantities.Add(Name, LengthExp, MassExp, TimeExp, CurrentExp, TemperatureExp, MolarAmountExp, LuminousIntensityExp)

 

If you mean to add a unit to a channel use this:

 

dim oChn
set oChn = Data.Root.ChannelGroups("MyGroup").Channels("MyChannel")
oChn.Properties("unit_string").Value = "MyUnit"

Greetings

Walter

Member
A._Baumann
Posts: 29
0 Kudos

Re: Add Unit with VBS

thanks, I was looking a solution for the 2. case. But it´s great to kill two birds with one stone. Have a nice weekend!

Member
Tweedy
Posts: 12
0 Kudos

Re: Add Unit with VBS

[ Edited ]

I added this code to get in-ozf as a unit.  It says it was added to the collection but I do not see it when I go to the units cell.

 

When using this code, is it a one shot deal and the units are now a part of the catalog or does the VBS need to be rerun.

 

Sure would have been nice if in-ozf would just be a standard value for torque.

 

dim oQuantities, oMyQuantity

set oQuantities = UnitCatalog.Quantities

Set oQuantity = oQuantities.Add("ozinf", 1,0,0,0,0,0,0)

Member
Tweedy
Posts: 12
0 Kudos

Re: Add Unit with VBS

.... So of course after I made my initial post I find in HELP that adding a new unit can be done right in the unit cell in the properties display.  Problem is I don't get asked to add and thus get the Add Symbol dialog.  I'm using DIADEM 2012 Trial.

 

So I did this to make sure what I supposedly added in my previous post would be gone.

   dim oQuantities, oMyQuantity

   set oQuantities = UnitCatalog.Quantities

   Set oQuantity = oQuantities.Remove("ozinf")

 

I still don't get the Add Symbol dialog BUT I did find out that under Settings | Options | Units I could add what I needed.  I'm learning!

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page