|
OK, so your first issue is that the code, when it works, will only work once. Because you only reset the array once. Or is it meant to be cumulative ?
Angelinna wrote: private int negate(int x)
{
if (x == 1) return 0;
return 1;
}
Not sure that you call this, but is it really worth writing a function for ? How about just writing this:
return 1 - x;
and 1-x is something you can just code inline instead of making a call, surely ?
I'd have expected you'd need to use the & operator to work out what bits are set in the original number, what you're doing here seems to me to be doomed to fail.
bitstring[nDecimal] = carry;
This will just crash if nDecimal > 7 and won't ever do anything useful.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Ya , not really sure of what am doing. Would like the code to work for both positive and negative integers and should take care of any "out of range" errors.......
Otherwise would appreciate tips or web where I may read more on this.
Thanks.
|
|
|
|
|
|
Christian Graus wrote: reads to me like a two's complement is the same as !x + 1.
Signed numbers are stored as two's complement, so the easiest way to get it is to cast a signed number to an unsigned number:
int negAnswer = -42;<br />
uint twosComplement = (uint)negAnswer;
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi, I have two forms that both open windows, I need to get the response from a checkbox on Form2 and use it with Form1, Form2 is not a dialogue and needs to open all the time. Any ideas? Thanks.
|
|
|
|
|
Delegates.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
As Christian said - use delegates. Simple example I've given before here[^].
Edited link!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
modified on Friday, August 22, 2008 3:23 AM
|
|
|
|
|
The link "Here" leads nowhere ?
|
|
|
|
|
Edited the link - thanks for pointing it out.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
Create 1 form & 1 userform a couple of buttons etc,etc , put the userform inside the form and check this out ok?!
I think you can read the code bellow.
/////////////////////////////////////////////
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
userControl11.MyTextEvent += new UserControl1.MyDelegate(userControl11_TextEvent);
userControl11.visibility_ev += new UserControl1.MyDelegate2(userControl11_visibility);
}
protected void userControl11_TextEvent(string textToSet)
{
textBox1.Text = textToSet;
}
protected void userControl11_visibility(bool visibility_b)
{
textBox1.Visible = visibility_b;
}
}
///////////////////////////////////
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
public delegate void MyDelegate(string textToSet);
public event MyDelegate MyTextEvent;
private void button1_Click(object sender, EventArgs e)
{
if (MyTextEvent != null) //Checks if anyone has registered the event.
MyTextEvent("This is a sample text");
}
public delegate void MyDelegate2(bool visibility_dl);
public event MyDelegate2 visibility_ev;
private void button2_Click(object sender, EventArgs e)
{
if (button2.Text == "Hide")
{ visibility_ev(false); button2.Text = "Show"; }
else
{ visibility_ev(true); button2.Text = "Hide"; }
}
}
//////////////////////////////////////////
nelsonpaixao@yahoo.com.br
|
|
|
|
|
no need for delegates, if form 1 called form 2 and you have problems passing values from form 2 to form 1 just make accessor methods from form 2 that after form 2 is closed, you can get the values from form 2.. you can also make use of again accessor methods if you want to pass values from form 1 to form 2 that before showing form2, set first the values then show form 2
|
|
|
|
|
don´t use 2 forms, use 1 form and load userforms inside, like what i showed you before.
I would use many form, for exemple, if i wanted to create a chat application (to load private chat windows).
But ... you are the boss i don´t know what you are trying to achieve.
Good Luck
nelsonpaixao@yahoo.com.br
|
|
|
|
|
Hi there,
I would like find one or two open source projects that use test-driven development in good practices.
I will use them to understand how unit testing works in real world.
(The language can be Java or C#, does not matter so much.)
Any suggestion would be appreciated,
Regards,
sarp
|
|
|
|
|
NUnit, look at the tests for itself!
|
|
|
|
|
I want to see how test driven developed project goes and learn something from their experience via understand their code(open-source).
|
|
|
|
|
Hi all.
I've two picture box overlapping.In it I load .png file (with trasparent border).
But i can't see only the first PictureBox.
I've read a lot on internet but i haven't find a solution.
How can i enable the trasparency?
Thanks.
|
|
|
|
|
Try using a Panel instead to load the png file in. Set it's BackColor to to Color.Transparent . This should do it.
|
|
|
|
|
Or try using this wonderfull tutorial: http://www.codeproject.com/KB/GDI-plus/CsTranspTutorial3.aspx[^]
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_______________________________________________________________________________________
My programs never have bugs, they just develop random features.
_______________________________________________________________________________________
Computers are so strange, you just yawn good and proper and they've got something new out! R. A.
|
|
|
|
|
I've already try to set it as trasparent but it not work.
|
|
|
|
|
Hi, I'm developing a C# user control to be hosted in IE6. The user control needs to be able to reach out and grab values that are assigned to elements in the Web form that hosts the user control. The Web form is contained in a JSP (not ASP.NET) and uses javascript. Obviously the Web form has a reference to the user control, but how does the user control get a reference to the Web form (parent container) that hosts it so that the user control can read element values in the Web form? I know how to make the Web form pass values to the user control, but I don't know how to make the user control get values from the Web form. Any help would be appreciated.
|
|
|
|
|
You cannot host C# user controls in JSP pages. Period. Only ASP.NET can.
Chuck Norris has the greatest Poker-Face of all time. He won the 1983 World Series of Poker, despite holding only a Joker, a Get out of Jail Free Monopoloy card, a 2 of clubs, 7 of spades and a green #4 card from the game UNO. In the movie "The Matrix", Chuck Norris is the Matrix. If you pay close attention in the green "falling code" scenes, you can make out the faint texture of his beard. Chuck Norris actually owns IBM. It was an extremely hostile takeover.
|
|
|
|
|
Thanks, Dogcow Farmer.
I realized from your answer that I did not phrase my question well. I should have called it an ActiveX control. I developed it starting as a user control in VS but then added some interfaces that allow it to function as an ActiveX control (IObjectSafety, IPropertyNotifySink). I am not asking it to post back to the server; it is all client-side.
I found a page that suggests implementing IOleObject[^], but it doesn't explain how to implement this interface or how to get a reference to the container after the interface is implemented. The interface definition at MSDN[^] does not provide that information, either.
If anyone knows how to give a C# ActiveX control a reference to its containing browser, either using IOleObject or some other way, I would appreciate any help you can give me.
|
|
|
|
|
ActiveX is even worse. It's insecure, IE-only, and pretty much a living heck to work with. Besides, C# is near impossible to host in ActiveX.
Chuck Norris has the greatest Poker-Face of all time. He won the 1983 World Series of Poker, despite holding only a Joker, a Get out of Jail Free Monopoloy card, a 2 of clubs, 7 of spades and a green #4 card from the game UNO. In the movie "The Matrix", Chuck Norris is the Matrix. If you pay close attention in the green "falling code" scenes, you can make out the faint texture of his beard. Chuck Norris actually owns IBM. It was an extremely hostile takeover.
|
|
|
|
|
Hello
Im writing an application that will implement its own custom exceptions
Just wanted to hear if anyone has any input before I start on how to do this "best practise"??
Cheers
Spaz
|
|
|
|
|
Derive new classes from existing exceptions. Use ApplicationException as a base, not Exception.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|