Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

visual basic


  • Please log in to reply

#1
MaverickSidewinder

MaverickSidewinder

    Member

  • Member
  • PipPipPip
  • 257 posts
Hey guys, i would like to know how to search for a determined character in a textbox.

For example:

A person writes: "Hello, my name is Google." in the textbox.

In the code i want to make an "If" statement that says that: if there is the word Google in the textbox the person isn't a human being (obviously this is a very stupid example)...

How do i do this, if i can do it...?

Thanks again! :tazz:
  • 0

Advertisements


#2
genyouinu

genyouinu

    New Member

  • Member
  • Pip
  • 1 posts
you could try the Instr ,InstrRev or StrComp function.

# Instr - Determines if one string is found within a second string
* i = Instr (starthere, string1, string2)
# InStrRev - Determine if one string is found in a second, starting at the end
* i = InStrRev (string1, string2, start)
# StrComp - Compares two strings
* result = StrComp (string1, string2)
  • 0

#3
MaverickSidewinder

MaverickSidewinder

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 257 posts
Thanks for the reply...

But i was looking for something more specific; something that will let me find like "a" in the word: bat
  • 0

#4
warriorscot

warriorscot

    Member 5k

  • Retired Staff
  • 8,889 posts
There is but my VB is so rusty i cant think of how the module would go, its a fairly common script though, you should be able to get the modules code from an internet site or from a book.
  • 0

#5
Ctrl_Alt_Del

Ctrl_Alt_Del

    Member

  • Member
  • PipPip
  • 74 posts
Instr will let you find a in the word bat as will instrrev.

if instr("bat","a") > 0 then
you found a in the word bat
end if
  • 0

#6
MaverickSidewinder

MaverickSidewinder

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 257 posts
Ok...thanks! :tazz:
  • 0

#7
Hai Mac

Hai Mac

    Member

  • Member
  • PipPipPip
  • 260 posts
Watch out! It should be => 0, because 0 means the searched string is right at the beginning of the text :tazz:
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP