11-17-2010 09:48 PM
I have the following code written in VB.Net using NiDAQmx. I have the need to have the same code written in VB6. Can someone give me the equivalent calls in VB6 using NiDAQmx?
Imports NationalInstruments.DAQmx Public Class frmDIO Private sPort As String = "Port1" Private sDevices() As String = Nothing Private sOutputLines() As String = Nothing Private sInputLines() As String = Nothing Private sPorts() As String = Nothing Private sSerialNumber As String Private sDeviceID As String Private Sub frmDIO_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim sDAQDevice As String Dim sDAQPorts As String Dim sString As String sDevices = DaqSystem.Local.Devices sPorts = DaqSystem.Local.LoadDevice(sDevices(0)).DOPorts For Each sDAQDevice In sDevices cbDigitalIOCard.Items.Add(DaqSystem.Local.LoadDevice(sDAQDevice).ProductType & " " & DaqSystem.Local.LoadDevice(sDAQDevice).DeviceID) Next sDAQDevice cbDigitalIOCard.Text = cbDigitalIOCard.Items(0) For Each sDAQPorts In sPorts cbPort.Items.Add(sDAQPorts) Next sDAQPorts cbPort.Text = cbPort.Items(0) End Sub Private Sub PortValue_Changed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Port1.PortValueChanged Dim digitalWriteTask As New Task() Dim OutputChannel As DOChannel Dim bInvertLines As Boolean Dim iSlashPos As Integer = cbPort.Text.IndexOf("/") Dim sPortName As String = cbPort.Text.Substring(iSlashPos + 1, cbPort.Text.Length - (iSlashPos + 1)) If Port1.Inverted Then lblPortValue.Text = 255 - Port1.State Else lblPortValue.Text = Port1.State End If OutputChannel = digitalWriteTask.DOChannels.CreateChannel(cbPort.Text, sPortName, ChannelLineGrouping.OneChannelForAllLines) ("Dev1/Port1/Line0", "Line0", ChannelLineGrouping.OneChannelForEachLine) digitalWriteTask.Start() bInvertLines = OutputChannel.InvertLines digitalWriteTask.Stop() OutputChannel.InvertLines = Not chkPortInversion.Checked Dim writer As DigitalSingleChannelWriter = New DigitalSingleChannelWriter(digitalWriteTask.Stream) writer.WriteSingleSamplePort(True, Decimal.ToUInt32(lblPortValue.Text)) digitalWriteTask.Dispose() End Sub End Class
11-18-2010 06:49 PM
Hi Tim,
You should be able to find all the examples and the documentation you need under the Program Files>National Instruments>Measurement Studio in your computer.
11-18-2010 07:01 PM
I've already looked. There is nothing there for VB6...
11-23-2010 07:06 PM
Sorry Tim,
I meant to say that you should look on this directory:
<>\National Instruments\NI-DAQ\Examples\DotNET2.0\
When you select the examples, you will see that you can choose from visual basic or C sharp.