Visual Basic 6.0 Programming Demo. Rigol DS2072A, DS2202A, DS2000A Series

Add to My manuals
390 Pages

advertisement

Visual Basic 6.0 Programming Demo. Rigol DS2072A, DS2202A, DS2000A Series | Manualzz

3 Programming Demos

RIGOL

Visual Basic 6.0 Programming Demo

The program used in this demo: Visual Basic 6.0

The function realized in this demo: control the on/off state of any channel.

1. Build a standard application program project (Standard EXE) and name it as MSO2000A_Demo_VB.

2. Click the Existing tab of ProjectAdd Module. Search for the visa32.bas file in the include folder under the NI-VISA installation path and add the file.

3. Add two buttons to represent CH1 and CH2 respectively. Add two Labels (Label1(0) and Label1(1)) to represent the status of CH1 and CH2 respectively (when the channel is enabled, it dispays the color of the channel; when the channel is disabled, it displays gray), as shown in the figure below.

4. Open the General tab in ProjectProject1 Properties and select Form1 in the Startup Object dropdown box.

MSO2000A/DS2000A Programming Guide 3-13

RIGOL

3 Programming Demos

5. Double-click CH1 to enter the programming environment. Add the following codes to control CH1 and CH2. The codes of CH1 are as shown below; the codes of CH2 are similar.

Dim defrm As Long

Dim vi As Long

Dim strRes As String * 200

Dim list As Long

Dim nmatches As Long

Dim matches As String * 200

Dim s32Disp As Integer

' acquire the usb source of visa

Call viOpenDefaultRM(defrm)

Call viFindRsrc(defrm, "USB?*", list, nmatches, matches)

' Open the device

Call viOpen(defrm, matches, 0, 0, vi)

' Send the command to query the status of CH1

Call viVPrintf(vi, ":CHAN1:DISP?" + Chr$(10), 0)

' Acquire the status of CH1

Call viVScanf(vi, "%t", strRes) s32Disp = CInt(strRes)

If (s32Disp = 1) Then

' Send the setting command

Call viVPrintf(vi, ":CHAN1:DISP 0" + Chr$(10), 0)

Label1(0).ForeColor = &H808080 'Gray

Else

Call viVPrintf(vi, ":CHAN1:DISP 1" + Chr$(10), 0)

Label1(0).ForeColor = &HFFFF& 'Yellow

End If

' Close the device

Call viClose(vi)

Call viClose(defrm)

6. Save and run the project and a single exe program will be obtained. When the oscilloscope is correctly connected to the PC, the ON/OFF control of any channel can be realized.

3-14 MSO2000A/DS2000A Programming Guide

advertisement

Related manuals

advertisement

Table of contents