Sample Code - Count Words in Web App

In 2026r1.1, the following code works for a Web app.

Controls:

  1. tc – TextField
  2. zc – Label

Var i As Integer = tc.Text.CharacterCount
Var s As String = tc.Text

// ReplaceAll is replacing two spaces for a single space.
s = s.ReplaceAll(" ", " “)
// ReplaceLineEndings exploited for universal search for all endings
s = s.ReplaceLineEndings(” ")

Var j As Integer = s.CountFields(" ")

zc.Text = “Words:” + j.tostring + " - Characters: " + i.ToString + “”

I hope this helps people avoid burning two or three hours hacking it out without using WebEx or iterative code.