National Instruments 374318A-01 Network Card User Manual


 
Chapter 4 Getting Started with Measurement Studio
© National Instruments Corporation 4-23 Measurement Studio for MCC User Manual
Generating and displaying the data
1. Double-click the button control to display the
Form1 code, with the
cursor inside the click event handler of the button control.
2. Add the following code to read a raw data point from a specified
channel on the Measurement Computing device, convert the data to
volts, and display the value on the graph.
[VB.NET]
Dim I As Integer
Dim WrtString As String = "val?"
Dim RdBufSize As Integer = 100
Dim NlChar As Char = "\n"
Dim NullChar As Char = "\0"
Dim PrimaryAddress As New Address(2)
Dim BoardNum As Integer = 0
' Open a gpib device
Dim Device As New Device(BoardNum, PrimaryAddress)
' Allocate a buffer to hold the data
Dim Buffer As IntPtr =
System.Runtime.InteropServices.Marshal.AllocHGlobal(RdBufSize)
' Read and plot 100 samples
For I = 0 To 99
' Write the string (val?) to the Fluke45
Device.Write(WrtString)
' Read the response from the Fluke45
Dim S As String = Device.ReadString(RdBufSize)
' Replace the newline character with a null and