tate Posted February 1, 2004 Posted February 1, 2004 I'm sure there has to be a simple way of doing this but I have spent hours pouring over web pages and books but can't get started in the right direction! What I would like to do is evaluate a text box to determine if there is an even number of characters. I thought I could do use something like this; IEEERemainder(txtField.Length, 2) If the returned value was greater than 0 then apparently there would not be an even number of characters. However the results were rather unpredictable. Any suggestions would be greatly appreciated. Tate Quote
NK2000 Posted February 1, 2004 Posted February 1, 2004 do you mean by even that it is dividable by 2? (english is not my native language) if yes then use this if (txtField.Length % 2) // code for even else // code for not even if i understood you wrong, then please tell me :) Quote
tate Posted February 1, 2004 Author Posted February 1, 2004 I'm not aware of any such syntax. What does the "%" character do? I can't find any reference to it in the Visual Studio help index. Thanks for the reply. Quote
Administrators PlausiblyDamp Posted February 1, 2004 Administrators Posted February 1, 2004 The code given is C# - % is the modulus operator (it returns the remainder after dividing two numbers) if you are using vb then there is a mod function If txtField.Length Mod 2 = 0 then 'even else 'odd end if Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
NK2000 Posted February 1, 2004 Posted February 1, 2004 oh this vb.... i just love c# (c-style) syntax :) Quote
tate Posted February 1, 2004 Author Posted February 1, 2004 Appears the Mod function returns the same thing as the IEEERemainder function. Either will work fine now that I understand them better. Thanks for everyone's input. Tate Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.