ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

including a variable in cmax

This is a very simple one... but it is slowly driving me mad.

 

I have some data, i want to know the maximum, but i want to go through several channels so i'm using a variable for my channel number....

 

Option Explicit  'Forces the explicit declaration of all the variables in a script.

dim data
dim maxval
dim minval

data = "ch(" " [1]/[2] " " ) "
maxval=CMax("&data& " )
minval=CMin(ch("&data& " )

 

I get an error of " An invalid text operand is used within the index operation of the formula CHNMAXVAL(0) : "

 

I've tried various syntaxes and it still won't work...

 

(i added in some spaces on this post to stop the code being full of smiley faces)

 

cheers.

0 Kudos
Message 1 of 2
(3,677 Views)

Hello Tom!

 

Keep it simple and try this:

Option Explicit

dim data
dim maxval
dim minval

data = "[1]/[2]"
maxval=CMax(data)
minval=CMin(data)

Matthias

Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 2 of 2
(3,663 Views)