Results 1 to 2 of 2

Thread: If statment wont execute

  1. #1

    Thread Starter
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547

    Angry

    Code:
    if(c_code.substring(0,6) == "money=")
    Ok this little line wont execute, im traying to figure out why. My whole code is this.

    Code:
    private void cheat_keyPress(Object source, KeyPressEvent e)
    	{
    	String c_code;
    		String c_parse;
        char c_char;
    		Form1 mon = new Form1();
    	long c_line;
    		c_char = e.getKeyChar();
    			
    		if(c_char == 13) {
    				//c_code = cheat.getText();
    		
    		 
    		 c_code = cheat.getText();
    			// c_code = c_code.substring(0,6);
    		 //cheat.setText(c_code);
    		
    			
    		//button1.setText(c_code.substring(0,6));	
    		 if(c_code.substring(0,6) == "money=") {
    		
    		 c_parse = c_code.substring(6,c_code.length());
    			 c_line = integer.valueOf(c_parse).intValue();
    		
    		 mon.addmoney(c_line,true);
    		
    													
    		 }
    			
    		}
    		
    	
    	
    	
    	}
    I know the keypress works, because if i add a statment before the if(c_code) then it will execute.
    I type in money=50000 (cheat for a game)
    and hit enter, and it wont recognize the money=.
    Any ideas?
    ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet?

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    The if statement is executed allright it's just that it always will evaluate as false.
    What you are doing is comparing two objects and check if they reference the same object and they don't.
    Change the if statement to this:
    Code:
    if(c_code.substring(0,6).equals("money="))
    Good luck!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width