Getting first text part before space?

I am trying to extract the first part of a string by splitting the string in parts using the spaces between the words, but I cannot get the code right. Where do I go wrong?

Var rs As RowSet
var FullName as string
Try
  rs = app.db.SelectSQL("SELECT * FROM preferences")
  
  FullName  = rs.Column("FullUserData").StringValue //Text field
Catch error As DatabaseException
  MessageBox("DB Error: " + error.Message)
End Try

Var FirstName As String

FirstName = Split(FullName, " ")

WinFileDialoge.lblWindowTitle.Text = "Welcome

to StoryCraft New Edition, " + FirstName + “!”

Either FirstName needs to be an array or use nthfield e.g. FirstName = FullName.nthField(" ", 1)

After the Split() command, Firstname is an array.
If you want the first element of the array, try

WinFileDialoge.lblWindowTitle.Text = "Welcome to StoryCraft New Edition, " + FirstName(0) + “!”

1 Like

Thanks, Wayne, this works!

How have I been using Xojo all these years and been completely unaware of nthfield until now? This is one of those “where have you been all my life” methods, LOL. Thank you Wayne.

You have the String related commands (etc.) here.