Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

phil05

VB string question

This topic is 5280 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How can I do this in VB? Idea is this... player-> do you have a sword? armorer -> Yes, I have one lying around here. So, it has to find "sword" in sInput.text, stored as a string. Any help is appreciated.
If sInput.Text = "sword" Then
    GameMain.Text = "Armorer -> Yes, I have one lying around here." + vbCrLf
End If
 

Share this post


Link to post
Share on other sites
Advertisement
Take a look at the
InStr 
function. It will return 0 if the word you''re looking for isn''t in the string that is to be searched in.

However, parsing your sentences this way won''t always get you satisfying results. Suppose the player says ''Can I give you my sword back in return for the money I payed for it?'' and the armorer still answers ''Yes, I have one lying around here.''

- Christoph

---
Teamwork Software - Stuff That Does Something

Share this post


Link to post
Share on other sites
If you want to parse the string yourself (to look for multiple keywords or whatever), look into the Mid$ function, which allows you to extract a portion of a string into a new variable.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!