Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

how to use cwmatrix unitvector function

Trying to figure out how to use cwmatrix.unitvector.  Looks straightforward but I always get type mismatches. 
Thanks for any feedback.
 
Private Sub Command1_Click()  'operates on #'s pasted into grid
Dim spec1() As Variant
Dim xx As Integer
Dim zz as integer
Dim norm() As Variant
Dim xyyy As Variant
xx = grid1.DataRowCnt
ReDim spec1(xx)
'ReDim norm(xx)

For zz = 1 To xx
    grid1.Col = 1
    grid1.Row = xx
    spec1(xx) = grid1.Text
Next zz
xyyy = CWMatrix1.UnitVector(spec1(), norm)
End Sub
0 Kudos
Message 1 of 2
(5,783 Views)
Hi Larry,

I believe you are getting that error because you are returning a single Variant from CWMatrix1.UnitVector to what you've defined as an array of Variants in the line

Dim norm() As Variant

Try removing the parentheses from that line.
Here is a snippet of example code that works:

  Dim x As Variant, norm As Variant, UnitVector As Variant
  ReDim x(0 To 2)
  For i = 0 To 2
      x(i) = i
  Next i
  UnitVector = CWMatrix1.UnitVector(x, norm)


Also, I believe that you are currently overwriting spec1(xx) xx number of times with the same row from grid1.
I think you want to use

For zz = 1 To xx
    grid1.Col = 1
    grid1.Row = zz
    spec1(zz) = grid1.Text
Next zz

Hope this helps Larry, have a good one!

Dan Weiland
Applications Engineer
National Instruments
Dan Weiland
0 Kudos
Message 2 of 2
(5,769 Views)