How to make "if text does not contain _ then" in Xojo?

I’m trying to make a web browser that can search with Google if the text isn’t a URL. It’s pretty simple. If the text doesn’t contain “.” (or something else) I want it to search with Google.

Here’s what I have so far:

If TextField1.text does not contain "." then

Any help with this?

If TextField1.Text.IndexOf(".") = -1 Then

1 Like

That works beautifully. Thanks!

If you do this a lot, you might want to write a string extension function:

function DoesNotContain(extends s as string, target as string) as boolean
  return s.IndexOf(target) = -1
end function

If TextField1.Text.DoesNotContain(".") then
which might be easier to read and understand.

You could even write it so it extends the textField:

function DoesNotContain(extends tf as TextField, target as string) as boolean
  return tf.text.IndexOf(target) = -1
end function

Then your code is simply:
If TextField1.DoesNotContain(".") then


Hey, there, I’m back.

What if I wanted a specific word to go to a specific website.
For example, I want “dneail/stream” to go to

And if its possible, can I make a label display the current webpage.

You may want to read this Xojo blog post, “Updated Tutorial: Active Words”, and check out the downloadable project.

1 Like

That’s not what I wanted.

If I type “dneail/stream” into the text box, I want HTMLViewer1 to take me to

My apologies. I figured it out.

The code I used what

If SearchField1.Text="<text>" Then

then continue this process