|
to know what is the error;
use:
try
{
...
}
catch()
{
...
}
finally()
{
}
******************************
The best things in life are free
******************************
modified on Friday, April 4, 2008 3:14 AM
|
|
|
|
|
I am trying to make a calculator out of C# and the last thing I am doing now is for interaction to the calculator using a keyboad. So what I did was to create a keypress event for the main form that whenever a key is pressed, the event method will be triggered. I dont know what i'm doing wrong but whenever I press a key on the keyboard, the value of the key doesn't show... do you have any example on how to do this?
|
|
|
|
|
Hi Silvyster,
Hard to help you as I can not see your code. Anyways, I am assuming you have a User Interface for users to interact with the calculator. Do you have buttons for each number of the calculator? If you do each button has a Click, KeyPress, KeyUp, KeyDown event. You need to handle these events by simply setting the display to the value of the key pressed. Remember you have to filter the input as users can not enter characters such as &, @, h etc.
If you can explain what your UI looks like then I can help you.
Let me know if you have any additional questions.
|
|
|
|
|
Thanks for the reply... yeah i've been thinking about the button interface too but what if i dont have any buttons? can't I just place the ONKEYPRESS on the FORM itself?? I did try but it doesnt show the numbers I pressed
|
|
|
|
|
Hi,
When the form has focus and the user presses keys, you can handle the KeyPress, and KeyUp event. Where do you want to show the number? A text box, a label? For example if you are using a textbox then within the handler you will write:
YourTextBox.Text = number
|
|
|
|
|
In your form's Load event, add
this.KeyPreview = true;
|
|
|
|
|
How do I publish / distribute either on a CD or for an eMail an XNA Windows game?
I've tried things but they don't work... Like MSDN. I DO know that you can't use the regualr IDE options, but that's it. Please help.
- I love D-flat!
- Need. More. Code.
modified on Thursday, April 3, 2008 8:58 PM
|
|
|
|
|
Hi,
I have the following:
namespace Server.Layer1
{
public class BaseClass : MarshallByRefObject
{
public enum SomeEnum
{
Zero = 0,
One = 1
}
abstract public IMyInterface CreateImplmentor(SomeEnum anEnum);
}
}
Here is IMyInterface
namespace Server.Layer2
{
public interface IMyInterface
{
bool Save(Student aStudent);
event AnEventHandler SomethingHappened;
}
public delegate void SomethingHappened(object sender, EventInfo e);
}
I have registered the class which implements the BaseClass functionality and register it using a
console application host. Compiles fine.
I have a client but when it connects to BaseClass, exception is thrown at this line:
BaseClass classReceived = (BaseClass ) RemotingServices.Connect(typeof(BaseClass),
"http://localhost:65100/RemoteClass");
Exception is: "Trying to create a proxy to an unbound type."
Student is Serializable. BaseClass is MarshalByRefObject and so is the class which implements the IMyInterface. I am not sure what the problem could be. If a class inherits from MarshalByRefObject and has delegates or events, do they need any special attributes?
Please help,
Thanks
|
|
|
|
|
I'm trying to make an application that will be run and will not need it's exe anymore (it will be on a removable device so you run application, remove the device and the app should be still running).
Have questions? try my e-mail l.holota[.at - sign.]hotmail.com
|
|
|
|
|
Lukas Holota wrote: I'm trying to make an application that will be run and will not need it's exe anymore
Sounds interesting, thanks for telling us.
led mike
|
|
|
|
|
|
You could also have a third exe on your flash drive that, when loaded, copies the "real" exe to your temp directory on the local computer, then instantiates that executable. This coupled with the idea presented by a previous poster (the person who suggested a small loader program on your hard drive to load the other into memory) should minimize temp filespace, prevent the actual executable from being saved on the HD, AND prevent the user from needing to manually copy the executable from the flash drive to the HD. Hope this helps,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
|
The background is that I am designing a custom event which is a new thing for me.
I have a piece of code that is not consuming an event which I am puzzled with.
I can see the heardPhrase event being raised using the degugger.
However the CommandHeard method never gets called.
Now I tried the same piece of code using static methods etc in another piece of code and everything was ticketyboo.
Any help, clues gratefully received.
public Listen listen = new Listen();
public MainForm()
{
listen.heardPhrase += new Listen.ListenEventHandler(CommandHeard);
}
public void CommandHeard(object sender, ListenEventArgs e)
{
lstCommands.SelectedIndex = e.PhraseIdx;
}
You always pass failure on the way to success.
|
|
|
|
|
GuyThiebaut wrote: I can see the heardPhrase event being raised using the degugger.
We can't see it because you didn't post that code and point to where your breakpoint is set.
led mike
|
|
|
|
|
Just solved it.
Basically the event handling class needed satanic static members and methods so the following failed:
public class Listen
{
public delegate void ListenEventHandler(object sender, ListenEventArgs e);
public event ListenEventHandler heardPhrase;
public void Heard(int p)
{
ListenEventArgs sp = new ListenEventArgs(p);
heardPhrase(null, sp);
}
}
This worked:
public class Listen
{
public delegate void ListenEventHandler(object sender, ListenEventArgs e);
public static event ListenEventHandler heardPhrase;
public static void Heard(int p)
{
ListenEventArgs sp = new ListenEventArgs(p);
heardPhrase(null, sp);
}
}
You always pass failure on the way to success.
modified on Thursday, April 3, 2008 5:20 PM
|
|
|
|
|
I want User put something like this ....
xx123xx here x is Alphabetic word
Id has to be 7 char.
first 2 char is Alphabetic
Last 2 char is alphabetic
Middle 3 to 5 char should be number....
Is tha any one can help me..
-Thanks
Peter
|
|
|
|
|
I suggest you do some research on Regular Expressions[^].
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
What exactly to u need?
To Validate that the string is in your Format?
if so just :
use the maskedTextBox and define the MAsk Property to :
aa000aa
define the MaskInputReject Event
it will check the format itself
(in the event give a message like "Wrong Format"
in a MessageBox)
Have Fun
Never forget it
|
|
|
|
|
I find maskedinputs quite buggy imo i think the more elegant solution would be regular expressions
A pessimist sees the difficulty in every opportunity; an optimist sees the opportunity in every difficulty I am a Optimist
|
|
|
|
|
gspiteri wrote: I find maskedinputs quite buggy
Welcome to VS C#, there a Lot of bugs
i did what u Thought about it's working fine
but i guess u have some other things in between
Hope i've been helpfull
Have Fun
Never forget it
|
|
|
|
|
half-life wrote: Welcome to VS C#, there a Lot of bugs
lol i hear you half-life
A pessimist sees the difficulty in every opportunity; an optimist sees the opportunity in every difficulty I am a Optimist
|
|
|
|
|
Use Regex for this.You can get many example in c#, javascript just search in google.
Sarvesh Upadhyay
Senior Software Engineer
Birlasoft India Ltd.
Microsoft Certified Professional Developer in Dotnet 2.0 Enterprise Application
|
|
|
|
|
HI,
I'm Trying to read from ini file like this :
<br />
string ToReturn = "";<br />
GetPrivateProfileString("CATEGORY1", "CATEGORY1_KEY1", "", ToReturn, 255, iniFilePath);<br />
but i get nothing
anyone?
THANKS
Have Fun
Never forget it
|
|
|
|
|
Hi,
if ToReturn is to be an output of your method, you need to use the ref or out keyword,
both where you define and where you use the method.
I suggest you read the documentation on these keywords.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|