startCommandButton.Enabled = True
Exit Sub
End If
For iu = 0 To 0
StopTask ' Call the StopTask module to stop the DAQmx task.
Next ' startCommandButton.Enabled = True
Estado_Digital
Salida_Digital
Exit Sub
ErrorHandler:
If taskIsRunning = True Then
DAQmxStopTask taskHandle
DAQmxClearTask taskHandle
taskIsRunning = False
End If
'
startCommandButton.Enabled = True
MsgBox "Error:" & Err.Number & " " & Err.Description, , "Error"
End Sub
For i = 0 To 255
'Consultamos el valor de la tecla mediante el Api. _
Si se presion devuelve -32767 y mostramos el valor de i
If GetAsyncKeyState(i) = -32767 Then
If i = vbKeyLeft Then
bitCheckBox(6).Value = 1
Shape3(0).FillStyle = 0
Shape3(1).FillStyle = 0
Else
bitCheckBox(6).Value = 0
Shape3(0).FillStyle = 1
Shape3(1).FillStyle = 1
End If
If i = vbKeyRight Then
bitCheckBox(7).Value = 1
Shape4(0).FillStyle = 0
Shape4(1).FillStyle = 0
Else
bitCheckBox(7).Value = 0
Shape4(0).FillStyle = 1
Shape4(1).FillStyle = 1
End If
If i = vbKeyUp Then
bitCheckBox(4).Value = 1
Shape2(0).FillStyle = 0
Shape2(1).FillStyle = 0
Else
bitCheckBox(4).Value = 0
Shape2(0).FillStyle = 1
Shape2(1).FillStyle = 1
End If
If i = vbKeyDown Then
bitCheckBox(5).Value = 1
Shape1(0).FillStyle = 0
Shape1(1).FillStyle = 0
Else
bitCheckBox(5).Value = 0
Shape1(0).FillStyle = 1
Shape1(1).FillStyle = 1
End If
End If
Next
Star_Boton.Value = True
End Sub
startCommandButton.Enabled = True
Exit Sub
End If
arraySizeInBytes = 8
bufferSize = 255
' Re-initialize a dynamic array to hold values read off the digital lines
ReDim readArray(arraySizeInBytes)
' Start the task running, and read from the digital lines.
DAQmxErrChk DAQmxStartTask(taskHandle)
DAQmxErrChk DAQmxReadDigitalLines(taskHandle, 1, 10#, _
DAQmx_Val_GroupByChannel, readArray(0), arraySizeInBytes, _
sampsPerChanRead, numBytesPerSamp, ByVal 0&)
For i = 0 To 7
bitCheckBoxS(i) = readArray(i)
Next
' Display a window indicating the number of samples per channel read.
samplesPerChannelReadLabel.Caption = "Samples / Line Read = " & sampsPerChanRead
samplesPerChannelReadLabel.Visible = True
Exit Sub
ErrorHandler:
If taskIsRunning = True Then
DAQmxStopTask taskHandle
DAQmxClearTask taskHandle
taskIsRunning = False
End If
' startCommandButton.Enabled = True
MsgBox Err.Number & " " & Err.Description, , "Error"
End Sub
If ValidateControlValues Then
'
startCommandButton.Enabled = True
Exit Sub
End If
arraySizeInBytes = 8
' Re-initialize an array that holds the digital values to be written
ReDim writeArray(arraySizeInBytes)
For i = 0 To arraySizeInBytes - 1
writeArray(i) = bitCheckBox(i)
Next
' Start the task running, and write to the digital lines.
DAQmxErrChk DAQmxStartTask(taskHandle)
DAQmxErrChk DAQmxWriteDigitalLines(taskHandle, 1, True, 10#, DAQmx_Val_GroupByChannel,
writeArray(0), sampsPerChanWritten, ByVal 0&)
' Display a window indicating the number of samples per channel read.
samplesPerChannelWrittenLabel.Caption = "Samples / Line written = " & sampsPerChanWritten
' samplesPerChannelWrittenLabel.Visible = True
Exit Sub
ErrorHandler:
If taskIsRunning = True Then
DAQmxStopTask taskHandle
DAQmxClearTask taskHandle
taskIsRunning = False
End If
MsgBox "Error: " & Err.Number & " " & Err.Description, , "Error"
End Sub