Should be a really easy if statement

  • Thread starter Thread starter Jonathan Brown
  • Start date Start date
J

Jonathan Brown

I need to evaluate the context of a textbox to see if it already contains a
period. if it does then exit sub, else do this code.

If me.txtbox.text contains a period then
exit sub
else
code...
end if

Is there some sort of function for this? Something like a
contains(me.txtbox.text,".")

I hope this makes sense.
 
Correction.  evaluate the CONTENTS of a textbox, not context.








- Show quoted text -

Do you mean:

Public YourSub (....)

If me.txtbox.text.contains("whatsoever") = True Then

Exit Sub

Else

' ...Code

End if

End Sub
 
perfect!!! thank you. That's exactly what I needed. I knew it was something
simple.
 
Jonathan,

AFAIK is mostly this used to see if something exist in a string

if MyString.IndexOf(0,".") = -1 then 'there is no dot.
(you can concatinate that and find as well the second dot.

Cor
 
Correction. evaluate the CONTENTS of a textbox, not context.

One way to proceed with this sort of question would be to start
typing:
If me.txtbox.text.
At that point Intellisense will show you what methods are available.
Maybe you can see something that looks like it might do what you want.

Another approach is to realize that me.txtbox.text is a String, and go
look at the properties and methods of the string class. I prefer
Google for this rather than the built-in help. Googling for:
..NET string class
will probably show the MSDN documentation for the String class in the
first few hits.
 
Back
Top