gclib  2.0.8
Communications API for Galil controllers and PLCs
VB.NET

gclib ships with gclib.vb, a Visual Basic class which exposes the functionality of the gclib. In addition, a VB forms example is included which demonstrates how to use gclib.vb. The following instructions were performed on Visual Studio Professional 2013 and can be extended to other Visual Studio versions.

Running the included Visual Basic Example

For brevity, these instructions assume the default installation location of C:\Program Files (x86)\Galil\gclib.

Copy files

  • Navigate to a convenient, empty, writable location, e.g. C:\temp.
  • Copy the contents of C:\Program Files (x86)\Galil\gclib\examples\vb\2013_12.0\gclib_example to this location.

Open in Microsoft Visual Studio 2013

  • Open gclib_example.sln in Visual Studio. This demo was tested on MSVS 2013.

Add existing item, gclib.vb

  • In the Solution Explorer, right-click on gclib_example and choose Add->Existing Item...
  • Choose C:\Program Files (x86)\Galil\gclib\source\wrappers\vb\gclib.vb

Run Demo

  • Type F5 to run the program.
  • Type a valid GOpen() address in the text box and click Go.

Create Project from scratch with MSVC 2013

For brevity, these instructions assume the default installation location of C:\Program Files (x86)\Galil\gclib.

Configure Project

  • Launch Visual Studio 2013
  • Choose File->New->Project
  • In the New Project dialog, choose Visual Basic -> Windows Forms Application
  • Type gclib_example for the Name
  • Choose a Location, e.g. C:\Users\user\Desktop
  • Check Create directory for solution
  • Click OK, the project will configure itself
  • In the Solution Explorer, right click on Solution 'gclib_example' (1 project) and choose Configuration Manager...
    • In the gclib_example project row, click in the Platform column and choose <New...>
      • Choose x86 from Type or select the new platform:
      • Choose Any CPU from Copy settings from:
      • Check Create new solutions platform
      • Click OK.
    • If x64 support is also desired, repeat the <New...> procedure for x64
    • In the Active solution platform combobox at the top of the Configuration Manager dialog, choose <Edit...>
      • Select Any CPU and click the Remove button
      • Click Close
    • Close the Configuration Manager dialog
  • In the Solution Explorer, right-click on gclib_example and choose Add->Existing Item
    • Navigate to the installation location C:\Program Files (x86)\Galil\gclib\source\wrappers\vb
    • Choose gclib.vb
  • In the Solution Explorer double-click on gclib.vb
    • Note that there is a preprocessor definition starting with #if PLATFORM = "x86" Then and #ElseIf PLATFORM = "x64" Then
    • Note that these sections of code enable/disable with the choice of the Solution Platform x86/x64, usually found in the Visual Studio toolbar
    • If a non-default gclib installation location is used, the paths in these sections of code must be updated to reflect the dll locations

Add some simple code

  • In the Solution Explorer right-click on Form1.vb and choose View Code
  • Replace the text in Form1.vb with the following code
Public Class Form1
    Dim gclib As New Gclib()
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Text = "gclib simple example"
        Dim tb As New TextBox
        With tb
            .Multiline = True
            .Dock = DockStyle.Fill
            .Parent = Me
            Try
                'calls to gclib should be in a try-catch
                .AppendText("GVersion: " & gclib.GVersion() & vbCrLf)
                gclib.GOpen("192.168.0.42") 'Set an appropriate IP address here
                .AppendText("GInfo: " & gclib.GInfo() & vbCrLf)
                .AppendText("GCommand: " & gclib.GCommand("MG TIME") & vbCrLf)
            Catch ex As Exception
                .AppendText("ERROR: " & ex.Message)
      Finally
        gclib.GClose() ' Don't forget to close!
            End Try

        End With
    End Sub
End Class
  • In the gclib.GOpen() call, indicate a correct IP address for the controller that is used for this project
  • Hit F5 to run the project