Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C#]Split

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Wed Dec 10, 2008 10:31 pm    Post subject: [C#]Split Reply with quote

Split isn't working for me

I do this

Code:

void replace(){
string[] lines = richTextBox1.split('\n');
foreach (string s in lines)
{
if (s == "SetMousePos")
{
string message = s.Split(' ')[1];
uint myX = message.Split(',')[1];
uint myY = message.Split(',')[2];
pMouse.MousePos(myX, myY);
}
}
}


and I get these errors:
Code:

Error   1   'System.Windows.Forms.RichTextBox' does not contain a definition for 'split' and no extension method 'split' accepting a first argument of type 'System.Windows.Forms.RichTextBox' could be found (are you missing a using directive or an assembly reference?)   C:\Users\Landon\Desktop\C#\Teleporter\Teleporter\Form1.cs   52   43   Teleporter
Error   2   Cannot implicitly convert type 'string' to 'uint'   C:\Users\Landon\Desktop\C#\Teleporter\Teleporter\Form1.cs   58   32   Teleporter
Error   3   Cannot implicitly convert type 'string' to 'uint'   C:\Users\Landon\Desktop\C#\Teleporter\Teleporter\Form1.cs   59   32   Teleporter


Help appreciated :] sorry for asking many questions!

_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Dec 10, 2008 10:47 pm    Post subject: Reply with quote

What are you trying to do, parse something?

Perhaps you'd be better off taking a look at substrings.
Back to top
View user's profile Send private message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Wed Dec 10, 2008 11:57 pm    Post subject: Reply with quote

fixed, close please.
_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
Jonyleeson
Master Cheater
Reputation: 0

Joined: 03 May 2007
Posts: 484
Location: Hérault, France

PostPosted: Thu Dec 11, 2008 12:38 pm    Post subject: Reply with quote

You're trying to split the RichTextBox itself, you should be splitting the Text property :
Code:
string[] lines = richTextBox1.Text.Split('\n');


As for

Code:
uint myX = message.Split(',')[1];
uint myY = message.Split(',')[2];

You have to cast the string to a uint :

Code:
uint myX = uint.Parse(message.Split(',')[1]);
uint myY = uint.Parse(message.Split(',')[2]);
Back to top
View user's profile Send private message
ElJEffro
Grandmaster Cheater Supreme
Reputation: 0

Joined: 15 Apr 2007
Posts: 1881
Location: La Tierra

PostPosted: Mon Dec 15, 2008 4:25 pm    Post subject: Reply with quote

CoolCat wrote:
You're trying to split the RichTextBox itself, you should be splitting the Text property :
Code:
string[] lines = richTextBox1.Text.Split('\n');


As for

Code:
uint myX = message.Split(',')[1];
uint myY = message.Split(',')[2];

You have to cast the string to a uint :

Code:
uint myX = uint.Parse(message.Split(',')[1]);
uint myY = uint.Parse(message.Split(',')[2]);


Code:


uint myX;
uint myY;
if (!uint.TryParse(message.Split(',')[1], out myX) || !uint.TryParse(message.Split(',')[2], out myY))
MessageBox.Show("Error parsing parameters in line whatever");

That way you won't get an exception and you'll know if those are valid unsigned ints next to the commas Wink
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites