Visual Basic Sample source code
-- a very basic visual basic sample application --
-----   Level 1   -----
( use when no changing of   default configuration,   parameters required )   --




A little about this document
Quick jump to
About this document     Main Form Source Code sample     Main Module Source Code sample     Main Form Screenshots     Log File sample



This documentation was created using the sample application found within    .  
It's intended be used as a reference to understand the simplicity of interracting with the Model 201 using the combination of VisualBasic and our   M201_SP.DLL   dynamically linked library. The Library is included in the archive linked to above and all available   function calls   are well documented.

Although both the ready-to-run executable and DLL are included within that archive, it may not run unless you have other Visual Basic runtime components installed on your system - but it won't hurt anything to give it a try. If you are a developer who has the Visual Basic programming environment, you can simple load the files and run either within your development environment, or run   "M201_A.EXE"   (included in the archive) which has already been compiled. Although there are a lot of configuration and runtime options available through the DLL, only a handful are usually required for most needs.
































































The Main Form Screenshots
Quick jump to
About this document     Main Form Source Code sample     Main Module Source Code sample     Main Form Screenshots     Log File sample



 
ready to run
shows COM-selection available
starting run
shows   "frmBusy" - discussed below
running and logging to disk file
messages to let you know it's running

































































The Main Form Source Code file
Quick jump to
About this document     Main Form Source Code sample     Main Module Source Code sample     Main Form Screenshots     Log File sample



Option Explicit
Public  bRunning  As Boolean

Private Sub Form_Load( )
    txtMsgs = "click the  Run  button to start . . ."
End Sub

Private Sub ComboCOM_Click( )
    Dim bCom, bRetVal As Byte:  bRetVal = 3
    bCom = ComboCOM.Text
    bRetVal = EX_SetCOMport( bCom - 1 )
End Sub

Private Sub  btnRun_Click( )
    Dim  bRetVal  As Byte
    bRunning  = True
    frmBusy.Visible = True:  frmBusy.Left = 30: frmBusy.Top = 1800
    txtMsgs = "STARTING RUN -  w a i t . . .  .  .   .": DoEvents
    
    bRetVal = EX_Run( )  
    If  bRetVal   Then
        txtMsgs = "STARTED" & vbCrLf & "Acquiring data and logging to disk file" _
		     & vbCrLf & "    click  'STOP'  to stop the run ": ScrollText
        Label3.Visible = True:   Label4.Visible = True:   Line1.Visible = True
        ComboCOM.Enabled = False:   Label5.Enabled = False
    Else
        txtMsgs = vbCrLf & "FAILED TO START" & vbCrLf & "    click  'HELP'  button to find solutions "
        ScrollText
    End If
    frmBusy.Visible = False

    While bRunning = True
        DoEvents
    Wend
End Sub

Private Sub btnStop_Click( )
    Dim  bRetVal  As Byte
    bRetVal = EX_Stop( )
    If bRetVal Then
        bRunning = False
        txtMsgs = txtMsgs & vbCrLf & "STOPPED": ScrollText
    Else
        txtMsgs = txtMsgs & vbCrLf & "Did NOT STOP": ScrollText
    End If
    txtMsgs = txtMsgs & vbCrLf & "click the RUN button to start . . .  .  .   .": ScrollText
    Label3.Visible = False:   Label4.Visible = False:   Line1.Visible = False
End Sub

Private Sub btnExit_Click( )
    Unload frmMain
    End
End Sub

Public Sub ScrollText( )
    frmMain.txtMsgs.SelStart = Len(frmMain.txtMsgs) & vbCrLf
End Sub



































































The Main Module Source Code file
Quick jump to
Main Form Source Code sample     Main Form Screenshots     Log File sample     About this document



Option Explicit

' Here are the only functions required for this simple example  
Declare Function EX_Run Lib "M201_SP.dll" ( ) As Byte
Declare Function EX_Stop Lib "M201_SP.dll" ( ) As Byte

' The following is zero-based. For example for COM-1 bPort should be set to zero.
Declare Function EX_SetCOMport Lib "M201_SP.dll" (ByVal bPort As Byte) As Byte

































































Sample Log File
Quick jump to
Main Form Source Code sample     Main Module Source Code sample     Main Form Screenshots     About this document



Time / s   	0 - 0    	
00000.0   	1.4847893	
00000.1   	1.4847744	
00000.2   	1.4847792	
00000.3   	1.4847816	
00000.3   	1.4847762	
00000.4   	1.4847774	
00000.5   	1.4847816	
00000.6   	1.4847816	
00000.7   	1.4847732	
00000.8   	1.4847816	
00000.9   	1.4847792	
00001.0   	1.4847720	
00001.0   	1.4847762	
00001.1   	1.4847726	
00001.2   	1.4847786	
00001.3   	1.4847738	
00001.4   	1.4847726	
00001.5   	1.4847762	
00001.6   	1.4847726	
00001.7   	1.4847828	
00001.7   	1.4847762	
00001.8   	1.4847792	
00001.9   	1.4847762	
00002.0   	1.4847756	
00002.1   	1.4847792	
00002.2   	1.4847780	
00002.3   	1.4847714	
00002.4   	1.4847756	
00002.4   	1.4847798	
00002.5   	1.4847756	
00002.6   	1.4847786	
00002.7   	1.4847738	
00002.8   	1.4847792	
00002.9   	1.4847786	

Minimal System Interval:	0.08678
Applied Interval:        	0.08704
Subcycles averaged:      	35
Started:                 	Fri Nov 05 14:41:36 2004
Finished:                	Fri Nov 05 14:41:39 2004
Experiment Description:  	none







































































Contact us for sales or technical assistance
lawsnlab@lawsonlabs.com

on the web
http://www.lawsonlabs.com

© Lawson Labs Inc. All rights reserved
Last modified 1-13-05 Tim Van Dusen