⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vbtolv.frm

📁 VB和Labview编程应用
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "LabVIEW Activex Server Example From WWW.VIHOME.COM.CN"
   ClientHeight    =   4515
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7380
   LinkTopic       =   "Form1"
   ScaleHeight     =   4515
   ScaleWidth      =   7380
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox Tank3 
      BeginProperty DataFormat 
         Type            =   1
         Format          =   "0.00"
         HaveTrueFalseNull=   0
         FirstDayOfWeek  =   0
         FirstWeekOfYear =   0
         LCID            =   2052
         SubFormatType   =   1
      EndProperty
      Height          =   615
      Left            =   5760
      TabIndex        =   10
      Top             =   2880
      Width           =   1215
   End
   Begin VB.TextBox Tank2 
      BeginProperty DataFormat 
         Type            =   1
         Format          =   "0.00"
         HaveTrueFalseNull=   0
         FirstDayOfWeek  =   0
         FirstWeekOfYear =   0
         LCID            =   2052
         SubFormatType   =   1
      EndProperty
      Height          =   615
      Left            =   4320
      TabIndex        =   9
      Top             =   2880
      Width           =   1215
   End
   Begin VB.TextBox Tank1 
      BeginProperty DataFormat 
         Type            =   1
         Format          =   "0.00"
         HaveTrueFalseNull=   0
         FirstDayOfWeek  =   0
         FirstWeekOfYear =   0
         LCID            =   2052
         SubFormatType   =   1
      EndProperty
      Height          =   615
      Left            =   2760
      TabIndex        =   8
      Top             =   2880
      Width           =   1215
   End
   Begin VB.TextBox Result 
      BeginProperty DataFormat 
         Type            =   1
         Format          =   "0.00"
         HaveTrueFalseNull=   0
         FirstDayOfWeek  =   0
         FirstWeekOfYear =   0
         LCID            =   2052
         SubFormatType   =   1
      EndProperty
      Height          =   285
      Left            =   3240
      TabIndex        =   6
      Top             =   2040
      Width           =   3375
   End
   Begin VB.TextBox ArithmeticExpression 
      Height          =   285
      Left            =   3480
      TabIndex        =   5
      Top             =   960
      Visible         =   0   'False
      Width           =   3615
   End
   Begin VB.CommandButton Quit 
      Caption         =   "Quit"
      Height          =   615
      Left            =   120
      TabIndex        =   4
      Top             =   3360
      Width           =   1575
   End
   Begin VB.CommandButton Ex 
      Caption         =   "Exit LabVIEW"
      Enabled         =   0   'False
      Height          =   615
      Left            =   120
      TabIndex        =   3
      Top             =   2400
      Width           =   1575
   End
   Begin VB.CommandButton Run 
      Caption         =   "Run VI"
      Enabled         =   0   'False
      Height          =   615
      Left            =   120
      TabIndex        =   1
      Top             =   1440
      Width           =   975
   End
   Begin VB.CommandButton Launch 
      Caption         =   "Launch LabVIEW"
      Height          =   615
      Left            =   120
      TabIndex        =   0
      Top             =   480
      Width           =   1815
   End
   Begin VB.CheckBox ShowPanel 
      Caption         =   "Display VI Front Panel"
      Height          =   495
      Left            =   1200
      TabIndex        =   2
      Top             =   1560
      Width           =   1935
   End
   Begin VB.Label Label6 
      Caption         =   "Tank3"
      Height          =   375
      Left            =   5760
      TabIndex        =   14
      Top             =   2520
      Width           =   615
   End
   Begin VB.Label Label5 
      Caption         =   "Tank2"
      Height          =   375
      Left            =   4320
      TabIndex        =   13
      Top             =   2520
      Width           =   735
   End
   Begin VB.Label Label4 
      Caption         =   "Tank1"
      Height          =   375
      Left            =   2760
      TabIndex        =   12
      Top             =   2520
      Width           =   975
   End
   Begin VB.Label Label3 
      Caption         =   "tank1"
      Height          =   15
      Left            =   2760
      TabIndex        =   11
      Top             =   2760
      Width           =   135
   End
   Begin VB.Label Label2 
      Caption         =   "Result"
      Height          =   255
      Left            =   3240
      TabIndex        =   7
      Top             =   1680
      Width           =   975
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'This example program demonstrates how to call a LabVIEW VI and pass parameters
'to and from it from Visual Basic
'This example was built with Visual Basic 5.0.

'Dimension the array that contains the parameter names and values.
'These arrays contain the same number of elements are there are
'connections on the VIs connector pane
Dim ParamNames(0 To 3) As String
Dim ParamVals(0 To 3) As Variant


'Declare the object type of a lvApp and VI
Dim lvApp As LabVIEW.Application
Dim VI As LabVIEW.VirtualInstrument
Dim VIPath As String



Private Sub Form_Load()
    'Clear the form indicators
    Tank1.Text = ""
    Tank2.Text = ""
    Tank3.Text = ""
    Result.Text = ""
    
    'Initialize the variables & define the strings corresponding to
    'the VI connector labels. Note that the strings are case sensitive
    ParamNames(0) = "Tank1"
    ParamNames(1) = "Tank2"
    ParamNames(2) = "Tank3"
    ParamNames(3) = "Result"
End Sub


Private Sub Launch_Click()
    'Create a reference to LabVIEW
    Set lvApp = CreateObject("LabVIEW.Application")
    
    'Determine the path to the VI 调用vipath指定路径
    VIPath = "C:\Documents and Settings\Administrator\Desktop\tank.vi"
    
    'Assign an object reference to VI
    Set VI = lvApp.GetVIReference(VIPath)
                 
    Launch.Enabled = False
    Run.Enabled = True
    Run.SetFocus
    Ex.Enabled = True
End Sub
Private Sub Run_Click()
    'Get values from front panel objects
    ParamVals(0) = Tank1.Text
    ParamVals(1) = Tank2.Text
    ParamVals(2) = Tank3.Text
   
    
    'Check if front panel of VI should be displayed
    If ShowPanel.Value = 1 Then
        VI.ShowFPOnCall = True
    Else
        VI.ShowFPOnCall = False
    End If
    
    'Call the VI
    Call VI.Call(ParamNames, ParamVals)
    
    'Display the result
    Result.Text = ParamVals(1)
End Sub
Private Sub Ex_Click()
'Close LabVIEW
If Not IsNull(lvApp) Then
    lvApp.Quit
    Run.Enabled = False
    Ex.Enabled = False
    Launch.Enabled = True
    Launch.SetFocus
End If
End Sub
Private Sub Quit_Click()
    'Quit the application
    End
End Sub

Private Sub Text1_Change()

End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -