Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

If textbox has a word then this happens

ok I am pulling the source from a website and putting it into a textbox. I want to make it so that if the word "Troll" is anywhere in the textbox then something happens.

how would I do this? thanks
Code
if (textBox1.Text.Contains("Troll"))
{
   //Do Something
}
If TextBox1.Text.Contains("Troll") Then
'do things here
End If
Assert failure(PID 10704 [0x000029d0], Thread: 10960 [0x2ad0]): pBuffer != NULL
(Nov 22, 2014 08:20 PM)Aristocles Wrote:  If TextBox1.Text.Contains("Troll") Then
'do things here
End If

This is in the C# section, not the VB section.

Also format your code with the [code] tags :)
(Nov 22, 2014 08:19 PM)Programming Wrote:  
Code
if (textBox1.Text.Contains("Troll"))
{
   //Do Something
}
Fuck i tried that but had it setup wrong thats why it wasnt working, thanks so much
(Nov 22, 2014 08:22 PM)Jack_Soff Wrote:  Fuck i tried that but had it setup wrong thats why it wasnt working, thanks so much

No problem, have a nice night! 😁
[Image: humcMrl.png]

Seems like the better option to me. If you don't want to use regex, but still ignore case, you can use an overload of string.IndexOf and pass it StringComparison.OrdinalIgnoreCase.
(Nov 23, 2014 04:58 AM)Dialog Wrote:  [Image: humcMrl.png]

Seems like the better option to me. If you don't want to use regex, but still ignore case, you can use an overload of string.IndexOf and pass it StringComparison.OrdinalIgnoreCase.

This would be the better option being that it recognizes all casing and doesn't allow for words other than exactly "troll".
you could also do.

if (this.textBox1.text == "troll")
{

}
(Nov 22, 2014 08:19 PM)Programming Wrote:  
Code
if (textBox1.Text.Contains("Troll"))
{
   //Do Something
}

Smarter (Removes case sensitivity):
Code
if (textBox1.Text.ToLower().Contains("troll")) {
   //Do Something
}
Its a simple way of removing case sensitivity. There are other means to do so, this is just an example... >.>
I post my opinions, please try not to be offended... I am not saying I am superior, but my interpretation of what you are saying may be befuddling.
ok, maybe someone on this thread can help me, im making a small program which is just a textbox takes commands theres a pic https://i.gyazo.com/0057fa3c88aabf40da62...97aa5f.png and i want it to spit out an error when you type in something thats not a command, this is pretty much how i tryed to do it but it splits out the error as soon as you type something in, is there anyone for it to wait a few secounds?

if (TextBox1.Text.Contains("function"))
{
// function
}
if (TextBox1.Text.Contains("function1"))
{
// function1
}
else
{
MessegeBox.Show("this isnt a command");
}
PHP Code

<?php 
List<String> YouFucktard = new List<String>() { "faggot", "op", "anonymous", "69" };

if(
YouFucktard.contains(TextBox1.ToLower().Text))
{
    
MessageBox.Show("You just dun goofed");
} 
(Dec 6, 2014 08:09 AM)Fafaffy Wrote:  
PHP Code

<?php 
List<String> YouFucktard = new List<String>() { "friend", "op", "anonymous", "69" };

if(
YouFucktard.contains(TextBox1.ToLower().Text))
{
    
MessageBox.Show("You just dun goofed");
} 
that would be used to code multiple commands onto one function, yes?
i have coded a different function for each command and want it to tell me when im typing something that isnt a command, sorry if this doesnt make sense or is stupid to you, im new to this, thanks for replying.
(Dec 6, 2014 10:16 AM)Astek Wrote:  that would be used to code multiple commands onto one function, yes?
i have coded a different function for each command and want it to tell me when im typing something that isnt a command, sorry if this doesnt make sense or is stupid to you, im new to this, thanks for replying.

"You just dun goofed"

😏😏


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by Moon RockJul 22, 2016 07:53 AM 2 218 Jul 22, 2016 07:53 AM
Last Post: Moon Rock
[.NET] by ShadyShadowApr 26, 2014 06:30 PM 9 236 Apr 26, 2014 06:30 PM
Last Post: 0xDEAD10CC
[C] by monkey2008Oct 15, 2013 09:02 AM 4 115 Oct 15, 2013 09:02 AM
Last Post: pratap95