« Close

Datasheets and User Guides

App Notes

Software & Driver

 

C#, VB .NET for LJM - Windows

LJM .NET Examples (Software Platform)

C# and Visual Basic .NET examples for the LJM library.

LJM .NET Examples (Referencable)

Prerequisites

  • LabJack T7 or T4
  • LJM Library and .NET assembly - Install the LJM Library
  • .NET 2.0 or newer
  • Visual Studios 2008 or newer for projects. Code will work with Visual Studios 2005.
  • Operating system - Windows

Instructions

  1. Download/extract the .zip file attached at the top of this page.
  2. Navigate to the extracted DotNet_LJM folder.
  3. Open the example projects in Visual Studios to edit, build and run.

Refer to the download's README.txt file for more details. 

Code Snippets

C#

using System;
using LabJack;

namespace ReadSerialNumber
{
    class ReadSerialNumber
    {
        static void Main(string[] args)
        {
            int handle = 0;
            try
            {
                //Open first found LabJack.
                LJM.OpenS("ANY", "ANY", "ANY", ref handle);
                
                //Call eReadName to read the serial number from the LabJack.
                string name = "SERIAL_NUMBER";
                double value = 0;
                LJM.eReadName(handle, name, ref value);

                Console.WriteLine("eReadName result: ");
                Console.WriteLine("  " + name + " = " + value);
            }
            catch (LJM.LJMException e)
            {
                Console.Out.WriteLine("Error: " + e.ToString());
            }
        }
    }
}

Visual Basic

Imports LabJack

Module ReadSerialNumber

    Sub Main()
        Dim handle As Integer
        Dim name As String
        Dim value As Double = 0

        Try
            ' Open first found LabJack.
            LJM.OpenS("ANY", "ANY", "ANY", handle)

            ' Call eReadName to read the serial number from the LabJack.
            name = "SERIAL_NUMBER"
            LJM.eReadName(handle, name, value)

            Console.WriteLine("eReadName result: ")
            Console.WriteLine("  " & name & " = " & value)
        Catch ljme As LJM.LJMException
            Console.WriteLine("Error: " & ljme.ToString)
        End Try

    End Sub

End Module