473,412 Members | 2,994 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Help. Dot Net keep flagging an error remdim

Hi

I am trying to re-write some of the example code that Agilent gives for
VB to VB.Net.
In .Net I keep getting the error 'cannot change the number of
dimensions of an array'.

I have paste the module I am having an issue with. Can anyone help!
Thanks

WayneL

Module Module1

' Add the files visa32.bas and vpptype.bas, located in the
' directory vxipnp\Win95\include, to your Visual Basic
' project. Add the example code as a .bas module, and
' call main_34970A.
'UPGRADE_WARNING: Application will terminate when Sub Main() finishes.
Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1047"'
Public Sub Main()
Dim numberChannels As Short
Dim numberSweeps As Short
Dim Sweep As Short
Dim Readings() As Double
Dim Units() As String
Dim ChanNumb() As Short
Dim Time() As Date
Dim VISAaddress As String
Dim status As Integer
Dim viDefaultRM As Integer
Dim Instrument As Integer
Dim i As Short
Dim Channel As String

' Declair all the HFPS currents

Dim I_VADREF As Double
Dim I_VCC As Double
Dim I_VREF1 As Double
Dim I_VREF2 As Double
Dim I_VREF3 As Double
Dim I_VREF4 As Double
Dim I_VREF5 As Double
Dim I_VKAM5V As Double
Dim I_VKAML2 As Double
Dim I_VCCL As Double
Dim I_VCCL2 As Double
Dim I_BUCKL As Double
Dim I_BUCKH As Double
Dim I_BAT As Double
' Declair all the HFPS voltages
Dim V_VADREF As Double
Dim V_VCC As Double
Dim V_VREF1 As Double
Dim V_VREF2 As Double
Dim V_VREF3 As Double
Dim V_VREF4 As Double
Dim V_VREF5 As Double
Dim V_VKAM5V As Double
Dim V_VKAML2 As Double
Dim V_VCCL As Double
Dim V_VCCL2 As Double
Dim V_BUCKL As Double
Dim V_BUCKH As Double
Dim V_BAT As Double
HFPS.DefInstance.Show()

VISAaddress = "9"
status = viOpenDefaultRM(viDefaultRM)
status = viOpen(viDefaultRM, "GPIB::" & VISAaddress & "::INSTR", 0,
2500, Instrument)
If status < 0 Then
MsgBox("Unable to open Port")
End
End If
Configure_34970A(Instrument)
SetScan_34970A(Instrument, numberSweeps, numberChannels)

################################################## ##############
Problem 'cannot change the number of dimensions of an array'
Starts here!
################################################## ##############

' Size arrays depending on channel and sweep count
ReDim Readings(numberSweeps, numberChannels)
ReDim Units(numberSweeps, numberChannels)
ReDim ChanNumb(numberSweeps, numberChannels)
ReDim Time(numberSweeps, numberChannels)

################################################## ##############
' Get data one sweep at a time
For Sweep = 1 To numberSweeps
ReadData_34970A(Instrument, Sweep, numberChannels, Readings, Units,
ChanNumb, Time)
Next Sweep
status = viClose(Instrument)
status = viClose(viDefaultRM)
' Get the current reading from the datalogger
' Reading (Sweep number, channel)
I_VADREF = Readings(1, 1)
I_VCC = Readings(1, 2)
I_VREF1 = Readings(1, 3)
I_VREF2 = Readings(1, 4)
I_VREF3 = Readings(1, 5)
I_VREF4 = Readings(1, 6)
I_VREF5 = Readings(1, 7)
I_VKAM5V = Readings(1, 8)
I_VKAML2 = Readings(1, 9)
I_VCCL = Readings(1, 10)
I_VCCL2 = Readings(1, 11)
I_BUCKL = Readings(1, 12)
I_BUCKH = Readings(1, 13)
I_BAT = Readings(1, 14)

HFPS.DefInstance.T1CH1.Text = CStr(I_VADREF)
HFPS.DefInstance.T1CH2.Text = CStr(I_VCC)
HFPS.DefInstance.T1CH3.Text = CStr(I_VREF1)
HFPS.DefInstance.T1CH4.Text = CStr(I_VREF2)
HFPS.DefInstance.T1CH5.Text = CStr(I_VREF3)
HFPS.DefInstance.T1CH6.Text = CStr(I_VREF4)
HFPS.DefInstance.T1CH7.Text = CStr(I_VREF5)
HFPS.DefInstance.T1CH8.Text = CStr(I_VKAM5V)
HFPS.DefInstance.T1CH9.Text = CStr(I_VKAML2)
HFPS.DefInstance.T1CH10.Text = CStr(I_VCCL)
HFPS.DefInstance.T1CH11.Text = CStr(I_VCCL2)
HFPS.DefInstance.T1CH12.Text = CStr(I_BUCKL)
HFPS.DefInstance.T1CH13.Text = CStr(I_BUCKH)
HFPS.DefInstance.T1CH14.Text = CStr(I_BAT)
HFPS.DefInstance.Show()

End Sub
Sub Configure_34970A(ByRef Instrument As Integer)
Dim SCPIcmd As String
Dim actual As Integer
Dim Channel As String
Dim i As Short
Dim Slot As Short
' Set instrument to power on state
SCPIcmd = "*RST"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
' Configure all channels in channel list

' Configure all channels in channel list
' Slot =3 with all channels set to resistance Auto 6 ˝ digits
Slot = 3
For i = 1 To 20
Channel = VB6.Format(CStr(i), "00")
SCPIcmd = "Conf:Res Auto,(@" & CStr(Slot) & CStr(Channel) &
");:Res:NPLC 0.02,(@" & CStr(Slot) & CStr(Channel) & ")"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1,
actual)
Next i

End Sub
Sub SetScan_34970A(ByRef Instrument As Integer, ByRef numberSweeps As
Short, ByRef numberChannels As Short)
Dim SCPIcmd As String
Dim replyString As New VB6.FixedLengthString(256)
Dim actual As Integer

numberSweeps = 1
' Include the Measurement units with reading
SCPIcmd = "Format:Reading:Unit On"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
' Include the channel with reading
SCPIcmd = "Format:Reading:Channel On"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
' Include the time with reading
SCPIcmd = "Format:Reading:Time On"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
' Set up the scan List
SCPIcmd = "Route:Scan
(@301,302,303,304,305,306,307,308,309,310,311,312, 313,314,315,316,317,318,319,320)"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
' Configure the trigger source
SCPIcmd = "Trigger:Source Timer"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
' Set the time between scans
SCPIcmd = "Trigger:Timer 0.01"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
' Set the number of scans
SCPIcmd = "Trigger:Count " & Str(numberSweeps)
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
' Read the number of channels on scan list
SCPIcmd = "Route:Scan:Size?"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
Call viRead(Instrument, replyString.Value, 255, actual)
numberChannels = Val(replyString.Value)
' Arm the trigger with initiate
SCPIcmd = "Initiate"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
End Sub
Sub ReadData_34970A(ByRef Instrument As Integer, ByRef Sweeps As
Short, ByRef numberChannels As Short, ByRef Readings(,) As Double,
ByRef Units(,) As String, ByRef ChanNumb(,) As Short, ByRef Time(,) As
Date)
Dim Points As Short
Dim Channel As Short
Dim SCPIcmd As String
Dim actual As Integer
Dim replyString As New VB6.FixedLengthString(256)

' Get the data one channel at a time
For Channel = 1 To numberChannels
' Wait for reading in instrument memory
Do
SCPIcmd = "Data:Points?"
Call viWrite(Instrument, SCPIcmd & Chr(10),
Len(SCPIcmd) + 1, actual)
Call viRead(Instrument, replyString.Value, 255, actual)
Points = CShort(Left(replyString.Value, actual))
Loop Until Points >= 1
' Get one channel of data from instrument
SCPIcmd = "Data:Remove? 1"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) +
1, actual)
Call viRead(Instrument, replyString.Value, 255, actual)
' Remove the reading data from string
Readings(Sweeps, Channel) = CDbl(Mid(replyString.Value, 1,
15))
' Remove the units data from string
Units(Sweeps, Channel) = Mid(replyString.Value, 17, 3)
' Remove the time data from string
Time(Sweeps, Channel) =
System.DateTime.FromOADate(Val(Mid(replyString.Val ue, 21, 12)) / 86400)
' Remove the channel number from string
ChanNumb(Sweeps, Channel) = Val(Mid(replyString.Value, 34,
3))
Next Channel
End Sub
End Module

Sep 1 '05 #1
2 1882
On 1 Sep 2005 02:28:59 -0700, "WAYNEL" <ho**@wlawson.co.uk> wrote:
Hi

I am trying to re-write some of the example code that Agilent gives for
VB to VB.Net.


This NG is used by VB6 coders

- there are NGs for VB.NET
- to avoid confusing and misleading answers, ask in an appropriate NG

For the microsoft news server, try these newsgroups...

news://msnews.microsoft.com/microsof...dotnet.general
news://msnews.microsoft.com/microsof...t.languages.vb
news://msnews.microsoft.com/microsof....vsnet.general
news://msnews.microsoft.com/microsof...studio.general
news://msnews.microsoft.com/microsof....vstudio.setup

Sep 1 '05 #2
Hi,

You are trying to make 1 dimension array 2 dimensions that is
why you are getting the error. Try this instead

Dim readings(,) As Double

ReDim readings(10, 10)
Ken
-----------------------------
"WAYNEL" <ho**@wlawson.co.uk> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Hi

I am trying to re-write some of the example code that Agilent gives for
VB to VB.Net.
In .Net I keep getting the error 'cannot change the number of
dimensions of an array'.

I have paste the module I am having an issue with. Can anyone help!
Thanks

WayneL

Module Module1

' Add the files visa32.bas and vpptype.bas, located in the
' directory vxipnp\Win95\include, to your Visual Basic
' project. Add the example code as a .bas module, and
' call main_34970A.
'UPGRADE_WARNING: Application will terminate when Sub Main() finishes.
Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1047"'
Public Sub Main()
Dim numberChannels As Short
Dim numberSweeps As Short
Dim Sweep As Short
Dim Readings() As Double
Dim Units() As String
Dim ChanNumb() As Short
Dim Time() As Date
Dim VISAaddress As String
Dim status As Integer
Dim viDefaultRM As Integer
Dim Instrument As Integer
Dim i As Short
Dim Channel As String

' Declair all the HFPS currents

Dim I_VADREF As Double
Dim I_VCC As Double
Dim I_VREF1 As Double
Dim I_VREF2 As Double
Dim I_VREF3 As Double
Dim I_VREF4 As Double
Dim I_VREF5 As Double
Dim I_VKAM5V As Double
Dim I_VKAML2 As Double
Dim I_VCCL As Double
Dim I_VCCL2 As Double
Dim I_BUCKL As Double
Dim I_BUCKH As Double
Dim I_BAT As Double
' Declair all the HFPS voltages
Dim V_VADREF As Double
Dim V_VCC As Double
Dim V_VREF1 As Double
Dim V_VREF2 As Double
Dim V_VREF3 As Double
Dim V_VREF4 As Double
Dim V_VREF5 As Double
Dim V_VKAM5V As Double
Dim V_VKAML2 As Double
Dim V_VCCL As Double
Dim V_VCCL2 As Double
Dim V_BUCKL As Double
Dim V_BUCKH As Double
Dim V_BAT As Double
HFPS.DefInstance.Show()

VISAaddress = "9"
status = viOpenDefaultRM(viDefaultRM)
status = viOpen(viDefaultRM, "GPIB::" & VISAaddress & "::INSTR", 0,
2500, Instrument)
If status < 0 Then
MsgBox("Unable to open Port")
End
End If
Configure_34970A(Instrument)
SetScan_34970A(Instrument, numberSweeps, numberChannels)

################################################## ##############
Problem 'cannot change the number of dimensions of an array'
Starts here!
################################################## ##############

' Size arrays depending on channel and sweep count
ReDim Readings(numberSweeps, numberChannels)
ReDim Units(numberSweeps, numberChannels)
ReDim ChanNumb(numberSweeps, numberChannels)
ReDim Time(numberSweeps, numberChannels)

################################################## ##############
' Get data one sweep at a time
For Sweep = 1 To numberSweeps
ReadData_34970A(Instrument, Sweep, numberChannels, Readings, Units,
ChanNumb, Time)
Next Sweep
status = viClose(Instrument)
status = viClose(viDefaultRM)
' Get the current reading from the datalogger
' Reading (Sweep number, channel)
I_VADREF = Readings(1, 1)
I_VCC = Readings(1, 2)
I_VREF1 = Readings(1, 3)
I_VREF2 = Readings(1, 4)
I_VREF3 = Readings(1, 5)
I_VREF4 = Readings(1, 6)
I_VREF5 = Readings(1, 7)
I_VKAM5V = Readings(1, 8)
I_VKAML2 = Readings(1, 9)
I_VCCL = Readings(1, 10)
I_VCCL2 = Readings(1, 11)
I_BUCKL = Readings(1, 12)
I_BUCKH = Readings(1, 13)
I_BAT = Readings(1, 14)

HFPS.DefInstance.T1CH1.Text = CStr(I_VADREF)
HFPS.DefInstance.T1CH2.Text = CStr(I_VCC)
HFPS.DefInstance.T1CH3.Text = CStr(I_VREF1)
HFPS.DefInstance.T1CH4.Text = CStr(I_VREF2)
HFPS.DefInstance.T1CH5.Text = CStr(I_VREF3)
HFPS.DefInstance.T1CH6.Text = CStr(I_VREF4)
HFPS.DefInstance.T1CH7.Text = CStr(I_VREF5)
HFPS.DefInstance.T1CH8.Text = CStr(I_VKAM5V)
HFPS.DefInstance.T1CH9.Text = CStr(I_VKAML2)
HFPS.DefInstance.T1CH10.Text = CStr(I_VCCL)
HFPS.DefInstance.T1CH11.Text = CStr(I_VCCL2)
HFPS.DefInstance.T1CH12.Text = CStr(I_BUCKL)
HFPS.DefInstance.T1CH13.Text = CStr(I_BUCKH)
HFPS.DefInstance.T1CH14.Text = CStr(I_BAT)
HFPS.DefInstance.Show()

End Sub
Sub Configure_34970A(ByRef Instrument As Integer)
Dim SCPIcmd As String
Dim actual As Integer
Dim Channel As String
Dim i As Short
Dim Slot As Short
' Set instrument to power on state
SCPIcmd = "*RST"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
' Configure all channels in channel list

' Configure all channels in channel list
' Slot =3 with all channels set to resistance Auto 6 ˝ digits
Slot = 3
For i = 1 To 20
Channel = VB6.Format(CStr(i), "00")
SCPIcmd = "Conf:Res Auto,(@" & CStr(Slot) & CStr(Channel) &
");:Res:NPLC 0.02,(@" & CStr(Slot) & CStr(Channel) & ")"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1,
actual)
Next i

End Sub
Sub SetScan_34970A(ByRef Instrument As Integer, ByRef numberSweeps As
Short, ByRef numberChannels As Short)
Dim SCPIcmd As String
Dim replyString As New VB6.FixedLengthString(256)
Dim actual As Integer

numberSweeps = 1
' Include the Measurement units with reading
SCPIcmd = "Format:Reading:Unit On"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
' Include the channel with reading
SCPIcmd = "Format:Reading:Channel On"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
' Include the time with reading
SCPIcmd = "Format:Reading:Time On"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
' Set up the scan List
SCPIcmd = "Route:Scan
(@301,302,303,304,305,306,307,308,309,310,311,312, 313,314,315,316,317,318,319,320)"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
' Configure the trigger source
SCPIcmd = "Trigger:Source Timer"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
' Set the time between scans
SCPIcmd = "Trigger:Timer 0.01"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
' Set the number of scans
SCPIcmd = "Trigger:Count " & Str(numberSweeps)
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
' Read the number of channels on scan list
SCPIcmd = "Route:Scan:Size?"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
Call viRead(Instrument, replyString.Value, 255, actual)
numberChannels = Val(replyString.Value)
' Arm the trigger with initiate
SCPIcmd = "Initiate"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) + 1, actual)
End Sub
Sub ReadData_34970A(ByRef Instrument As Integer, ByRef Sweeps As
Short, ByRef numberChannels As Short, ByRef Readings(,) As Double,
ByRef Units(,) As String, ByRef ChanNumb(,) As Short, ByRef Time(,) As
Date)
Dim Points As Short
Dim Channel As Short
Dim SCPIcmd As String
Dim actual As Integer
Dim replyString As New VB6.FixedLengthString(256)

' Get the data one channel at a time
For Channel = 1 To numberChannels
' Wait for reading in instrument memory
Do
SCPIcmd = "Data:Points?"
Call viWrite(Instrument, SCPIcmd & Chr(10),
Len(SCPIcmd) + 1, actual)
Call viRead(Instrument, replyString.Value, 255, actual)
Points = CShort(Left(replyString.Value, actual))
Loop Until Points >= 1
' Get one channel of data from instrument
SCPIcmd = "Data:Remove? 1"
Call viWrite(Instrument, SCPIcmd & Chr(10), Len(SCPIcmd) +
1, actual)
Call viRead(Instrument, replyString.Value, 255, actual)
' Remove the reading data from string
Readings(Sweeps, Channel) = CDbl(Mid(replyString.Value, 1,
15))
' Remove the units data from string
Units(Sweeps, Channel) = Mid(replyString.Value, 17, 3)
' Remove the time data from string
Time(Sweeps, Channel) =
System.DateTime.FromOADate(Val(Mid(replyString.Val ue, 21, 12)) / 86400)
' Remove the channel number from string
ChanNumb(Sweeps, Channel) = Val(Mid(replyString.Value, 34,
3))
Next Channel
End Sub
End Module
Sep 1 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mr. Magoo | last post by:
I'm working with imaplib. I'm trying to flag (or move or copy - anything that takes a message_set as an argument) a bunch of messages with one command and am having trouble. === def...
1
by: Alpay Eno | last post by:
Hello all... I'm stuck, I cannot figure out how I should go about flagging conflicts on a sheduling app. I currently have 8 columns (school grades) that have class over the course of 9 periods. I...
2
by: nan.li.g | last post by:
I have this simple code below. When I compiled it, I got the following error. But after I removed the comment marker(//), i.e. explicitly defined a constructor, it becomes OK. The compiler...
17
by: EkteGjetost | last post by:
This is definitely not the smart thing to do as far as my learning goes, but desperate situations call for desperate measures. The final lab for my introduction to C programming class is due...
29
by: Joseph Geretz | last post by:
Use of unassigned local variable 'fs' Please see where I've indicated where the compiler is flagging this error in the method below. fs is initialized in the first line in the try block, so why...
3
by: Sky Sigal | last post by:
I coming unglued... really need some help. 3 days chasing my tail all over MSDN's documentation ...and I'm getting nowhere. I have a problem with TypeConverters and storage of expandableobjects...
3
by: Larry | last post by:
I've set up a list of image filesnames in a listview control(lvSrcFileList), I'm using the selectedIndexChange event to select which file is being displayed in a picturebox control(pbImagePreview)....
4
by: WAYNEL | last post by:
Hi I am trying to re-write some of the example code that Agilent gives for VB to VB.Net. In .Net I keep getting the error 'cannot change the number of dimensions of an array'. I have paste...
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.