1- Initialize NiseVirtualDevices Object.
Before you can do anything with any NISE Virtual Device – create a new one, edit an existing one, import configuration from Excel – you must first instantiate a NiseVirtualDevices object in VBA. A NiseVirtualDevices object is a top-level collection of all of the NISE configurations.
Dim nise As NiseVirtualDevices
Set nise = New NiseVirtualDevices
With a NiseVirtualDevices collection, nise, instantiated, you can now call different methods on the nise object, as well as get and set properties of the NISE object. Table 1 shows a summary of the methods and properties available for the object class NiseVirtualDevices.
Table 1: NiseVirtualDevices Methods and Properties
2- Create or Open a NiseVirtualDevice Object.
Next you would want to declare an NiseVirtualDevice object and initialize it to create or modify a specific NISE Virtual Device.
Dim sevd As NiseVirtualDevice
Once your NiseVirtualDevice object, sevd, is declared, you can initialize the sevd object in one of two ways:
- Add a unique new NiseVirtualDevice
Set sevd = nise.Add(“NewSEVD”)
- Get an existing NiseVirtualDevice
Set sevd = nise(“ExistingSEVD”)
When creating or getting a NiseVirtualDevice, it is imperative that you incorporate error checking. For instance, if you try to name a new Nise VirtualDevice using the name of another Nise Virtual Device, you will get an error. Or if you try to get an existing NiseVirtualDevice, and one cannot be found that matches the name you asked for, you will get an error. (The examples at the end of this document illustrates good error checking habits.)
With a NiseVirtualDevice object, sevd, instantiated, you can now get and set properties of the sevd object. Table 2 lists the methods and properties available for the object class NiseVirtualDevice.
Table 2: NiseVirtualDevice Methods and Properties 3 - Add or Remove IVI Switches to a NiseVirtualDevice object.
Next, perform actions on the IviDevices property of sevd. You can declare a new IviDevices variable, and then access the properties of the IviDevices object. However, you can also skip this step and access the IviDevice properties via the sevd object.
Object classes IviDevices and IviDevice have the associated properties and methods liste in Table 3:
Table 3: IviDevices and IviDevice Methods and Properties To add a new IVI Switch to the list of IviDevices associated with NiseVirtualDevice sevd, call the following lines of code:
sevd.IviDevices("SampleSwitch").Comment = "This is a sample"
The above code will only work if there is an IVI Switch with a logical name that matches SampleSwitch. Otherwise, the code will result in errors.
If you wanted to have specific variables for sevd’s properties IviDevices and IviDevice, the above code can be broken up into the following lines of code:
Dim iviDevices As NiseIviDevices
Dim iviDevice As NiseIviDevice
Set iviDevices = sevd.iviDevices
Set iviDevice = iviDevices.Add("SampleSwitch")
iviDevice.Comment = "This is a sample"
Follow similar processes to remove IviDevices from a Virtual Device.
For an example of how to create a new Virtual Device and associate IVI Switch logical names with it from an Excel spreadsheet, see Create_Name_Add_IVI_Devices.xls.