📄 putgetworksheet.frm
字号:
VERSION 5.00
Begin VB.Form PutGetWorksheet
Caption = "Put/Get Worksheet"
ClientHeight = 5772
ClientLeft = 456
ClientTop = 708
ClientWidth = 5436
LinkTopic = "Form1"
ScaleHeight = 5772
ScaleWidth = 5436
Begin VB.ListBox ListRes
Height = 4080
Left = 3960
TabIndex = 7
Top = 480
Width = 1335
End
Begin VB.ListBox List2
Height = 4080
Left = 2040
TabIndex = 6
Top = 480
Width = 1335
End
Begin VB.ListBox List1
Height = 4080
Left = 120
TabIndex = 5
Top = 480
Width = 1335
End
Begin VB.OptionButton Plus
Caption = "/"
Height = 255
Index = 3
Left = 1560
TabIndex = 4
Top = 2640
Width = 375
End
Begin VB.OptionButton Plus
Caption = "*"
Height = 255
Index = 2
Left = 1560
TabIndex = 3
Top = 2280
Width = 375
End
Begin VB.OptionButton Plus
Caption = "-"
Height = 255
Index = 1
Left = 1560
TabIndex = 2
Top = 1920
Width = 375
End
Begin VB.OptionButton Plus
Caption = "+"
Height = 255
Index = 0
Left = 1560
TabIndex = 1
Top = 1560
Width = 375
End
Begin VB.CommandButton CommandCalculate
Caption = "Calculate in Origin"
Height = 495
Left = 1560
TabIndex = 0
Top = 5040
Width = 2175
End
Begin VB.Label Label2
Alignment = 2 'Center
AutoSize = -1 'True
Caption = "Column Operations"
Height = 195
Left = 1965
TabIndex = 9
Top = 120
Width = 1365
End
Begin VB.Label Label1
Alignment = 2 'Center
AutoSize = -1 'True
Caption = "="
Height = 195
Left = 3615
TabIndex = 8
Top = 2280
Width = 105
End
End
Attribute VB_Name = "PutGetWorksheet"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'This sample demonstrates use of:
' Get/PutWorksheet
' Execute
' LTStr
'Orign Automation Server methods
'Copyright OriginLab Corporation 2003.
'
Private Const nRow2s = 70#
Dim mat2(nRow2s - 1, 1 To 2) As Long 'Double 'Variant
Dim wksName As String, Opp As String
Dim bb As Boolean
'make sure Origin reference is checked (VB menu Project->References...)
'Dim oApp As Origin.Application 'for exclusive session
Dim oApp As Origin.ApplicationSI
Private Function ErrorFound(variable As Variant) As Boolean
ErrorFound = IsError(variable)
If ErrorFound Then
MsgBox "Error returned from " & _
"GetWorksheet(" & wksName & "...): " & CStr(variable)
End If
End Function
Private Sub UpdateList(ListName, DataName, nStart, nEnd, nCol)
ListName.Clear
Dim i As Integer
For i = nStart To nEnd
ListName.AddItem DataName(i, nCol)
Next i
End Sub
Private Sub CommandCalculate_Click()
'Put mat2 into Origin worksheet
bb = oApp.PutWorksheet(wksName, mat2)
'Fill the third column with results of chosen opperation
bb = oApp.Execute("col(Diff) = col(A)" & Opp & "col(B)", wksName)
'Get the results from the third column of wksNAme
vResult = oApp.GetWorksheet(wksName, 0, 2, -1, 2)
If ErrorFound(vResult) Then Exit Sub
'Fill the results list
UpdateList ListRes, vResult, 1, nRow2s, 1
End Sub
Private Sub Form_Load()
'Get a reference to the Origin Automation Server object
'Set obj = GetObject("", "Origin.Application") 'for exclusive session
Set oApp = GetObject("", "Origin.ApplicationSI")
'Create new Origin worksheet (LabTalk)
bb = oApp.Execute("win -t data")
If Not bb Then
MsgBox ("Error returned when trying to create window in Origin - Ending Application")
End
End If
'Get the name of the worksheet (LabTalk)
wksName = oApp.LTStr("%h")
'Append one column to the worksheet to store results
bb = oApp.Execute(wksName & "!wks.addcol(Diff)")
'Create sample data
For i = 0 To nRow2s - 1
For j = 1 To 2
mat2(i, j) = i + j
Next j
Next i
Plus.Item(0).Value = True
'initialize lists
UpdateList List1, mat2, 0, nRow2s - 1, 1
UpdateList List2, mat2, 0, nRow2s - 1, 2
ListRes.Clear
End Sub
Private Sub Plus_Click(Index As Integer)
ListRes.Clear
Select Case Index
Case 0
Opp = "+"
Case 1
Opp = "-"
Case 2
Opp = "*"
Case 3
Opp = "/"
Case Else
Opp = "+"
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -