|
pakpatel wrote: But now i want to chek if this user is uder 18 year or not
There is no way to tell without meeting in person, and even then it can be iffy.
Whenever a Website asks for my birthdate I use 1900-01-01 and watch what happens.
|
|
|
|
|
pakpatel wrote: But now i want to chek if this user is uder 18 year or not
That is not possible with the information given.
You can check if the date entered is at least 18 years ago. Just take the current date, subtract 18 years from it, and compare the dates:
if (enteredDate <= DateTime.ToDay.AddYears(-18)) ...
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thnks For Your Help..
I get it
Peter
|
|
|
|
|
Basically I have a dialog box that has a TextBox inside of it. The object is never deleted and the previous input values still stay filled whenever I open the dialog.
I'd like to add a handler so that when ShowDialog is called, I will able to clear the textbox, checkboxes and put the focus on the textbox.
I appreciate any help, and thanks for your time.
|
|
|
|
|
Either dispose the form when it is closed or clear the contents of the textbox in the load event of the form.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
A using block would clean that up nicely for you. Just remember that if you have your own crazy flavor of dialog that it implements IDisposable somewhere in the class hierarchy.
<code>
using(ShowDialog sd = new ShowDialog()){
sd.ShowDialog();
result = sd.Result();
}
</code>
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
How can I write a byte value to a textual file stream as a single-byte char? I'm using a StreamWriter instance. For example, assuming that myChar is a variable of type char with a value of 165, when I do this...
sw.Write(myChar);
...then two bytes are written to the file because .NET automatically converts that value (the old ASCII character N with a tilde accent mark) into Unicode. However, when I do this...
sw.Write((byte)myChar);
The hex string representation "A5" of the byte value 165 gets written. I don't want Unicode conversion, and I don't want a string representation. I want to stuff the actual hex value A5 (decimal 165, binary 10100101) into a single-byte slot in the output file.
I'm thinking I might have to use a BinaryWriter class instead, but wouldn't that be a headache when the rest of the file in the data is string data?
Thanks.
|
|
|
|
|
You could use BinaryWriter, or try to change the encoding of the text file (I don't know if that only applies to TextReader/Writer) to ASCII.
|
|
|
|
|
I tried adding a System.Text.ASCIIEncoding class in the StreamWriter constructor. Didn't really help. Any value above the normal alphabetic set is replaced with a "?" character (0x3F). So my value 165 (0xA5) gets obliterated anyway.
Guess I'll have to go binary.
Thanks.
|
|
|
|
|
Is there a way to change it to use 8-bit extended ASCII? ANSI or something?
|
|
|
|
|
You could use hex coded ascii... (Byte)0x45 -> "45"
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
Hi, my code reads a byte which is 0x41 hex. and I would like to convert it to ascii which is character "A"
int hex = s[a];
can somebody help me with this?
Thanks in advanced,
merh
|
|
|
|
|
Ummm... just stick it in a char ?
|
|
|
|
|
|
i am working on a program for school and it requires key input so when i press the "a" key a block of code will execute i would i do this i am using visual C# 2005 express edition i think it is something like Key_Down but i couldnt get it to work thanks is there somethat will run as long as the key is held down?
thanks mike
|
|
|
|
|
xxmikexx wrote: i think it is something like Key_Down but i couldnt get it to work
You handled the KeyDown event of which control or form?? If it's the form, did you also set the form's KeyPreview property to true?
|
|
|
|
|
ya i am working on something so while the "d" key is held down something will happen how would i do this i tried putting it in a button with a tutorial i found but it didnt seem to work it was something like
private void cmdright_KeyDown(object sender, EventArgs e CHANGED SOMETHING HERE)
|
|
|
|
|
The problem is that you used a button, which doesn't have the input focus for very long. Handle the KeyDown event of the Form.
|
|
|
|
|
In textbox..
when ever user write his address, He has to start with Numeric value then after all he can use what ever he want ?
if he not use numreic value, then message come up.
Can anyone help me with that?
-Thanks
Peter
|
|
|
|
|
create an event listener for the textbox textchanged event, parse the string, if the first character (or two or three, etc..) are numeric, then proceed, else, if the first char is not numeric, display a messagebox and clear the textbox.
|
|
|
|
|
but how do i chek that condition...i have to use substring or pls help me with that ?
Peter
|
|
|
|
|
use if(IsNum(textBox1.Text[0])),
As IsNum is a function you may create and takes a parameter of char to check if its a number.
|
|
|
|
|
pakpatel wrote: when ever user write his address, He has to start with Numeric value
Are you really, really sure about that?? You're making a bad assumption here...
|
|
|
|
|
Ya i know but what i do man..that's how they want ?
Peter
|
|
|
|
|
A good app starts with good solid requirements. Your customers are not software developers. They have no concept of what is and isn't best practice. If the customer wants something that is known to be bad practice, it's part of your job to hash this requirement out and make sure that the customer understands that this will affect the quality of the app and spell out what the potential pitfalls are, and have the customer sign off on the bad requirement. The last thing you need is to give the customer everything they wanted and them not give you what you wanted ($$$) because the app didn't do everything they envisioned it doing.
|
|
|
|