11-20-2009 04:49 PM
Hi I have a small sample code that I am trying to read and write to a source meter throught GPIB. It gives an error "type not defined" for NationalInstruments where I am declaring GPIB variable in the public form. Anyone know how to do this? I can communicate no problem in VB6, the examples for VB6 that come with the NI488.2 drivers are descent to follow and they have an explanation of the code for each section. The .NET examples are complete garbage, they don't explain anything at all as far as what they are doing in the code unlike the VB6 examples. Also the help manual for NI488.2 .NET is not nearly as well written or easy to follow as the non .NET manual is. If anyone has any ideas that would be great. It would be nice to actually be able to set up the meter to communicate. Once I can do that then I can actually trying some things. This has me going in circles. NationalInstruments.NI4882 is referenced in my project. Thanks for your help.
Imports NationalInstruments.NI4882
Public Class Form1
Public Keithley_ID As Integer
Public GPIB As NationalInstruments = New NationalInstrumentsPublic GPIBCard As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Ket_Channel As Integer
Ket_Channel = 26
GPIBCard = 0
Keithley_ID = GPIB.ildev(GPIBCard, Ket_Channel, 0, 10, 1, 0)
Dim Command As String
Dim Results As String = ""
Dim MaxDataToRead As Integer = 200
Command = "*IDN?"
GPIB.ilwrt(Keithley_ID, Command, Len(Command))
GPIB.ibrd(Keithley_ID, Results, MaxDataToRead) '
MsgBox(Results)
End Sub
End Class
11-23-2009 03:25 PM - last edited on 01-07-2010 03:02 PM by Support
Looks like you want to decalre your GPIB variable as a "Device" not "NationalInstruments". There are some shipping examples that should help get you on your feet. They are located here:
Win 7/Vista - C:\Users\Public\Documents\National Instruments\NI-488.2\Examples\DotNET3.5\
Win XP - C:\Documents and Settings\All Users\Documents\National Instruments\NI-488.2\Examples\DotNET3.5\
Let me know if this helps.
Regards,
02-05-2013 04:41 AM
it it also giving error to
Private GpibDevice As Device and
GpibDevice = New Device(CInt(boardIdNumericUpDown.Value), CByte(primaryAddressNumericUpDown.Value), CByte(currentSecondaryAddress))
please give me better solution for this.
02-05-2013 07:24 AM
@143143143 wrote:
it it also giving error to
Private GpibDevice As Device and
GpibDevice = New Device(CInt(boardIdNumericUpDown.Value), CByte(primaryAddressNumericUpDown.Value), CByte(currentSecondaryAddress))
please give me better solution for this.
What exactly is the error you are getting?
02-06-2013 12:09 AM
this code give error
Imports NationalInstruments.NI4882
Public Class Form1
Public Keithley_ID As Integer
Public GPIB As NationalInstruments = New NationalInstruments
Public GPIBCard As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Ket_Channel As Integer
Ket_Channel = 26
GPIBCard = 0
Keithley_ID = GPIB.ildev(GPIBCard, Ket_Channel, 0, 10, 1, 0)
Dim Command As String
Dim Results As String = ""
Dim MaxDataToRead As Integer = 200
Command = "*IDN?"
GPIB.ilwrt(Keithley_ID, Command, Len(Command))
GPIB.ibrd(Keithley_ID, Results, MaxDataToRead) '
MsgBox(Results)
End Sub
End Class
error in this line
Public GPIB As NationalInstruments = New NationalInstruments
error is
Type expected.
please give solution
Thanks
02-06-2013 07:26 AM - edited 02-06-2013 07:27 AM
error in this line
Public GPIB As NationalInstruments = New NationalInstruments
error is
Type expected.
please give solution
Thanks
That gives an error because that is wrong. Why do you insist on doing something that you were told is wrong?
Did you try the examples linked by pflores?
Did you try the solution suggested by pflores?