|
Oops, too slow. Already answered...
|
|
|
|
|
Hi all. Is it that i am using VS .Net 2003 that there is no method to clear a list box once it is populated. I need to clear the list Box but every time i attempt using the method Clear() from Class ListControls, i get an error. please help.
Wamuti: Any man can be an island, but islands to need water around them!
Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.
|
|
|
|
|
Hi Wamuti,
Try using the following line of code if it is a Bound ListBox:
<br />
this.listBox1.DataSource = null;<br />
For Unbound ListBox:
<br />
this.listBox1.Items.Clear()<br />
I hope this would be helpful.
John Adams
ComponentOne LLC.
www.componentone.com
modified on Thursday, September 4, 2008 10:33 AM
|
|
|
|
|
I will get back since im abit far from my codes.
Thanx alot.
Wamuti: Any man can be an island, but islands to need water around them!
Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.
|
|
|
|
|
What is the difference between;
Convert.Int32(myVariable)
Int32.Parse(myVariable)
(int)myVariable
Best Regards...
|
|
|
|
|
The former invokes a specific overload of the latter.
/ravi
|
|
|
|
|
Convert.ToInt32 will attempt to convert any type so long as a converter exists.
Int32.Parse will only attempt to convert a string.
(int) is an explicit cast - so long as the myVariable class/struct has an explicit(or implicit) operator that returns an int then it will be converted (by the class/struct that myVariable is an instance of - not by Int32)
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)
|
|
|
|
|
dataminers wrote: Convert.Int32(myVariable)
That will do different things depending on the type of myVariable. If it's a string, it will be parsed. If it's numeric (byte, short, float, double, et.c) it will be converted.
dataminers wrote: Int32.Parse(myVariable)
Only accepts a string, and tries to parse it into an int.
dataminers wrote: (int)myVariable
That depends on the type of myVariable. If it's an object reference pointing to a boxed int it will be unboxed. If it's numeric it will be converted.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi there
I'm currently building a simple downloader application. I need to provide Pause/Resume facility to the application. How can I do that?
(I use WebClient control) and the method DownloadFileAsync()
|
|
|
|
|
See this[^] article for an FTP analog of what you want to do.
/ravi
|
|
|
|
|
I have a WinForm app that needs to send data to, and retrieve data from a Web Service. Right now, it's done in the clear, but we want the data sent back and forth to be encrypted. I've suggested using HTTPS/SSL, but I'm not sure what to google for. Any help would be appreciated.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
What about encrypting the SOAP Message...
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Do these links help?/ravi
|
|
|
|
|
The first link, maybe (but it looks like supreme hassle to implement). The second link, no.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: I've suggested using HTTPS/SSL, but I'm not sure what to google for
Setting up SSL under IIS is pretty simple. This should help.[^]
I have never tried an SSL ULR for a WebService but according to the Documentation[^] it should just work.
Note: The Framework caches SSL sessions as they are created and attempts to reuse a cached session for a new request, if possible. When attempting to reuse an SSL session, the Framework uses the first element of ClientCertificates (if there is one), or tries to reuse an anonymous sessions if ClientCertificates is empty.
led mike
|
|
|
|
|
Easy as pie, just run the service on https. Further encryption would be overkill or just too enterprisey.
|
|
|
|
|
I don't think it's going to be "easy as pie". It seems to me that since I'm using the service from a Windows form app, I would have to encrypt outgoing data, and decrypt incoming data. The thing is, I'm not sure what to use - WSE 3.0 or WCF.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: It seems to me that since I'm using the service from a Windows form app, I would have to encrypt outgoing data, and decrypt incoming data.
Thats all automatic if you use SSL. Just host any webservice on SSL, and connect!
John Simmons / outlaw programmer wrote: The thing is, I'm not sure what to use - WSE 3.0 or WCF.
That has nothing to do with encryption, WSE defines security.
|
|
|
|
|
Given the code:
static void Main(string[] args)
{
double d = 0d;
d += 0.0963d;
d += 0.0029d;
d += 0.0654d;
d += 0.0386d;
d += 0.0526d;
}
why would d = 0.25579999999999997 after the final addition?
|
|
|
|
|
I would guess that at least one of these numbers cant be expressed exactly in binary, leading to a loss of precision
A simplified example:
0.3
could be approximated as 1/4 + 1/8 (0.01 + 0.001)
= .25 + 0.125
which is 0.375 i.e. a loss of precision
Obviously the .Net framework will have a more complex floating point mechanism to allow more possible numbers, but hopefully you get my point that some floating point numbers are hard to express in binary without some loss of information.
To solve the problem you could perhaps multiply all your floating point numbers by something, add them together and then divide again later - this sometimes will give a more precise answer
for example:
0.3 + 0.3
Approximated to 0.375 + 0.375 = .75 rather then .6
But:
((0.3 * 10) + (0.3 * 10)) / 10
=
(3 + 3) / 10
= 6 / 10 = .6
Converted into bin: 0.11
(which again is a loss of precision, but less so)
Again as a disclaimer, the maths I am trying to use to explain is over simplified and .Net is more complex then this!
Hopefully that helps,
Chris
[Edit: to elaborate on my point here is some test code I just wrote:
int i = 0;
i += 963;
i += 29;
i += 654;
i += 386;
i += 526;
double x = (double)i / 10000;
However I also tried the example given in the OP, and got the correct answer with no precision loss - different OS or version of .Net perhaps...
]
modified on Thursday, September 4, 2008 9:00 AM
|
|
|
|
|
|
this because precision in double data type, if you want to show just 4 digit precision, d.ToString("N4) you will give what you want
dhaim
programming is a hobby that make some money as side effect
|
|
|
|
|
If you want better accuracy - use decimal instead of double.
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)
|
|
|
|
|
First, you don't need the "d" notation after the numbers (and you could initialize d like so: double d = 0.0; .
Next, floating point math is not precise. Since a CPU is inherently an integer processor, performing floating point math results in an approximation.
Try using decimal for the math, and then cast it to a double.
decimal d = 0.0m;
d += 0.0963m;
d += 0.0029m;
d += 0.0654m;
d += 0.0386m;
d += 0.0526m;
double d2 = Convert.ToDouble(d);
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Thursday, September 4, 2008 9:34 AM
|
|
|
|
|
John Simmons / outlaw programmer wrote: Next, floating point math is not precise. Since a CPU is inherently an integer processor, performing floating point math results in an approximation.
Floating point math is done natively on every x86 from the Pentium forward. The rounding problem comes entirely from converting from base 2 (internal representation) to base 10. More specifically .1 (.01, .001. etc) is a repeating decimal in base 2 and cannot be represented exactly. This makes it impossible for the general case of floating point math to be done without rounding errors due to conversion.
To see the conversion of .1 to a binary decimal search for "Or for example, 0.1" in this WP article.
http://en.wikipedia.org/wiki/Binary_numeral_system[^]
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|