Application example – Flintec II PC-BASED User Manual

Page 32

Advertising
background image

FlintWeigh Technical Manual, Rev. 3.03 November 2011

Page 32 of 32

10.2. Application Example


Example 1 – Visual Basic:

Call of OLE function "Regist" in VB

-------------------------------------------------------
Dim scale As Object
'Create object and position the weight display
'(only once in the programme during initialisation)
Set scale = CreateObject("scale99.serv")
Call scale.Position(0,0)

'Recording
'(several times during normal operation)
print_str = scale.Regist

'Stop communication
'(only once in the programme before closing)
Call scale.Stop
-------------------------------------------------------



Example 2 - VisualBasicScript / Windows Scripting Host:

Call of OLE function "Regist2" in VBS

'------------------------------------------------------------
' Sample programme for use of OLE connection to FlintWeigh II
'------------------------------------------------------------
'## Create Shell-Object ##
Set ws = CreateObject("WScript.Shell")

'## Create OLE-Object for "FlintWeigh II" ##
Set scale = CreateObject("Scale99.Serv")

'## First neccesary command to "FlintWeigh II"=position(x,y) ##
scale.position 0,0

'## Info message and waiting till "FlintWeigh II" is ready ##
ws.popup "Wait for initialisation of OLE server" ,1
WScript.Sleep (10*1000)

'## Show FlintWeigh II window ***
scale.Show

'## Wait for scale is ready and do recording–format 2 ##
Do
regist2value = scale.regist2
Loop Until (left(regist2value,1)<>"E")

'## Show result of recording – format 2 ##
msgbox regist2value

'## Stop OLE-Server ##
scale.stop
'----- End of Sample programme -----




















www.flintec.com

Advertising