08-04-2009 06:19 AM
I am pretty new to .NET and I am trying to write an error handling loop to make sure my reads and writes to my instruments are ok.
Does anyone have some examples of code on how to do this?
Here is a copy of the read function I am creating:
Public Function Read(ByVal strInstrument As String) As String
Dim strRead As String
Dim strerr As String
Try
mbSession = CType(ResourceManager.GetLocalManager().Open(strInstrument), MessageBasedSession)
strRead = mbSession.ReadString()
Catch exp As Exception
strerr = exp.ToString
MessageBox.Show(exp.Message & strInstrument, "GPIB READ ERROR")
End Try
mbSession.Dispose()
Return (strRead)
End Function
Thanks in advance,
Michael
08-05-2009 01:18 PM
Mike,
When you install the NI-VISA driver, examples are installed by default to C:\Documents and Settings\All Users\Documents\National Instruments\NI-VISA\Examples . I was able to find a SimpleReadWrite example in the DotNET3.5\SimpleReadWrite\VB folder that shows how to read/write and handle errors properly. The code you posted looks good...is it able to run properly?