With .NET (VB or C#) you can create your own functions and classes that are called from GuiXT using the CallVB keyword. .NET is a Microsoft framework that provides an extensive class library — including functions for date and time calculations, text processing, database access, and much more. This makes it easy to implement tasks in VB.NET or C# that would be cumbersome in GuiXT alone.

VB.NET, C#, and other .NET Framework languages are largely interchangeable — they all compile to the same intermediate language and share the same class library. If you encounter an example or documentation that only shows code in one language, you can assume the same approach works in the other with minor syntactic adjustments. Throughout this documentation, examples are provided for both VB.NET and C# where possible, but any concept shown in only one language applies equally to the other.

In this example we show how to validate, parse, and modify dates using .NET. The GuiXT script builds the following screen:

GuiXT
del (0,0) (20,200)

Box (2,12) (14,62) "Date Handling"
InputField (4,14)	"Date" (4,34) size=20 name="inDate"

Pushbutton	(6,14) "Validate" process="validate_date.txt"
Pushbutton	(6,24) "Parse Date" process="parse_date.txt"


InputField	(8,14) "Days" (8,34) size=8 name="days" -numerical
InputField	(9,14) "Months" (9,34) size=8 name="months" -numerical
InputField	(10,14) "Years" (10,34) size=8 name="years" -numerical
InputField	(13,14) "New Date" (13,34) size=20 name="newDate" -readonly

Pushbutton	(9,44) "Add/Subtract Time" process="change_date.txt"

The user enters a date in the Date field. The three buttons then perform the following actions:

  • Validate – checks whether the entered date is valid in one of the supported formats.

  • Parse Date – returns the date in written-out form (e.g. "Monday, January 5, 2025").

  • Add/Subtract Time – adds or subtracts days, months, and years from the entered date and displays the result in the New Date field.

The corresponding .NET class DateHandler in the namespace Introduction contains three functions. First, an array with all supported date formats is defined — from yyyyMMdd to German (dd.MM.yyyy) and American (MM/dd/yyyy) notation. This array is shared by all three functions:

using System;
using System.Globalization;

namespace Introduction
{
    public class DateHandler
    {
        static readonly string[] valid_date_formats =
        {
            "yyyyMMdd",
            "yyyy-MM-dd",
            "yyyy-MM-d",
            "yyyy-M-dd",
            "yyyy-M-d",
            "dd.MM.yyyy",
            "d.MM.yyyy",
            "dd.M.yyyy",
            "d.M.yyyy",
            "MM/dd/yyyy",
            "M/d/yyyy",
            "MM/d/yyyy",
            "M/dd/yyyy"
        };

        // ... methods follow below ...
    }
}

IsValidDate uses DateTime.TryParseExact to check the given date against every entry in the format array. If the function returns True, the date is valid. In VB.NET the output value is captured in a temporary variable (dummy), since no discard operator like C#'s out _ is available:

public bool IsValidDate(string date)
{
    return DateTime.TryParseExact(
        date,
        valid_date_formats,
        CultureInfo.InvariantCulture,
        DateTimeStyles.None,
        out _
    );
}

ParseDate also parses the date using TryParseExact and, on success, returns it in written-out English form — e.g. "Monday, January 5, 2025". If the date is invalid, an empty string is returned:

public string ParseDate(string input)
{
    bool ok = DateTime.TryParseExact(
        input,
        valid_date_formats,
        CultureInfo.InvariantCulture,
        DateTimeStyles.None,
        out DateTime date
    );

    if (ok)
    {
        return date.ToString(
            "dddd, MMMM d, yyyy",
            new CultureInfo("en-US")
        );
    }

    return "";
}

ChangeDate iterates through the format array until the input date can be successfully parsed. The specified days, months, and years are then added — negative values subtract. The result is returned in the same format in which the input date was recognised. Optional parameters are declared in VB.NET with the Optional keyword and a default value:

public string ChangeDate(
    string input, int days = 0, int months = 0, int years = 0)
{
    foreach (var format in valid_date_formats)
    {
        if (DateTime.TryParseExact(
            input, format,
            CultureInfo.InvariantCulture,
            DateTimeStyles.None,
            out DateTime date))
        {
            date = date.AddDays(days);
            date = date.AddMonths(months);
            date = date.AddYears(years);
            return date.ToString(
                format, CultureInfo.InvariantCulture);
        }
    }
    return "";
}

Before the class can be used in GuiXT, two requirements must be met:

  • Class library with .NET Framework: The project must be compiled as a class library (DLL). The target framework must be .NET Framework version 4.0 or higher — not .NET Core or .NET 5+.

  • DLL directory: The compiled DLL must be copied into the directory specified in the GuiXT profile for .NET class libraries (VBDirectory). The interface library guinet.dll (included in the GuiXT setup) must also be present in this directory.

The three input scripts each call the .NET functions using CallVB:

validate_date.txt

GuiXT
callvb rval = Introduction.DateHandler.IsValidDate "&V[inDate]"
Message "&V[rval]"

parse_date.txt

GuiXT
callvb rval = Introduction.DateHandler.ParseDate "&V[inDate]"
Message "&V[rval]"

change_date.txt – missing values are set to "0" before the call:

GuiXT
if V[days=]
  Set V[days] "0"
endif
if V[months=]
  Set V[months] "0"
endif
if V[years=]
  Set V[years] "0"
endif

callvb rval = Introduction.DateHandler.ChangeDate "&V[inDate]" _
  "&V[days]" "&V[months]" "&V[years]"

Set V[newDate] "&V[rval]"

The result of ChangeDate is written directly into the New Date field. Empty fields for days, months, or years are set to "0" before the call so that the .NET function receives a valid integer value.