|
thanx man, ill look into it over the weekend!
it just hit 5pm here in south africa so im going home!
thanx again, have a go0d one!
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
I want to dial a number from COM port.I am using Nokia 6300 as a modem which is connected to USB port. Even though computer is accepting mobile as a modem i am getting error in port opening. Sample programs which i used to run application gives error "No phone is connected" or "Unable to open port as it is busy in other application".
So can anybody tell me what may be the problem & how to overcome from it? Can anybody give me correct code to dial a number from COM port in C#.Net?
|
|
|
|
|
It could be due to the baud rate. This[^] article is about sending SMS but it may help. Once connected you should be able to use standard AT commands to dial.
Dave
|
|
|
|
|
As you have said, the nokia modem is connected to USB port. Please make sure that you are using the same port in your application. A common mistake people do is to try to open a COM port #1 or #2 instead of USB one.
Manoj
Never Gives up
|
|
|
|
|
hi there,
i m having problem that i have some float value in string, and i want to convert it in float but the precision must be 4
e.g.
string a = "83.834244245";
float b = Convert.ToSingle(a);
now please tell how can i reduce precision ?
Becoming Programmer...
|
|
|
|
|
First create a subString of the required precision. Then Parse the string for the float value.
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
that will take too much time, i have about 1 lakh strings, please tell any short way
Becoming Programmer...
|
|
|
|
|
This seems a little clumsy but it works
float b = (float)Math.Round(decimal.Parse(a), 4);
The Math.Round method uses 'Bankers Rounding' which may not acheive the result you require. If not you may need to use this which is even clumsier
float b = float.Parse(decimal.Parse(a).ToString("N4"));
Dave
|
|
|
|
|
DaveyM69 wrote: float b = float.Parse(decimal.Parse(a).ToString("N4"));
thanks, it works
Becoming Programmer...
|
|
|
|
|
DaveyM69 wrote: This seems a little clumsy but it works
float b = (float)Math.Round(decimal.Parse(a), 4);
That's not clumsy at all. That's exactly what I would suggest.
DaveyM69 wrote: The Math.Round method uses 'Bankers Rounding' which may not acheive the result you require. If not you may need to use this which is even clumsier
float b = float.Parse(decimal.Parse(a).ToString("N4"));
Now, that is clumsy. Converting a string to a double, to a string, to a float... Why is there no base64 and serializing to xml in there?
If you want a different kind of rounding, just specify that in the call to Round:
float b = (float)Math.Round(decimal.Parse(a), 4, MidpointRounding.AwayFromZero);
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Guffa wrote: Why is there no base64 and serializing to xml in there?
I did say it was even clumsier!
I haven't come across MidpointRounding.AwayFromZero before - more learning to do
Dave
|
|
|
|
|
Hi,
if the values well are within int limits, then you can do things such as:
float b = Convert.ToSingle(a);
int b4= (int)(10000.0*b+0.5);
b=0.0001*b4;
This does not create any objects; variants of it will all have similar performance.
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.
|
|
|
|
|
i think DaveyM69 gave good solution, anyway thank you too
Becoming Programmer...
|
|
|
|
|
The bankers rounding, is that what you want?? (you do realize it produces even numbers only?)
or the clumsy and slow one with an unnecessary ToString() and Parse()??
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.
|
|
|
|
|
no, i dont want bankers rounding,
yeah i know your way is good, but a little bit long as i have to write it about in 100 lines in a big loop
so you can think 100 * 3 repeating lines will hard to understand and a little mistake can destroy the project
Becoming Programmer...
|
|
|
|
|
Hi,
you can put all three lines in a single one (not recommended).
you can turn it into a little method.
anyway, if you think you need it a hundred times, chances are there is something
wrong with your data representation to begin with. Normally there is no need to do so,
using arrays or collections should avoid a lot of code duplication (which normally is
a bad idea).
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.
|
|
|
|
|
oh yeah, a method is good idea, thanks
Becoming Programmer...
|
|
|
|
|
public static double GetValue(string what)
{
return multiplierDivider * (int)(multiplier * Convert.ToSingle(what) + 0.5);
}
what do you think about it
Becoming Programmer...
|
|
|
|
|
Luc Pattyn wrote: The bankers rounding, is that what you want?? (you do realize it produces even numbers only?)
No, it only rounds to an even number if the number is right in the middle of two possible results. I.e. both 1.00015 and 1.00025 would both be rounded to 1.0002, but 1.00014 would still be rounded to 1.0001.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Hi Guffa, you're right.
I forgot the details, since I decided long ago it was of no value to me.
I'm an engineer, so for me if 1.00015 rounds up, so should 1.00025
And I never understood the advantage, if any, of the banker's rounding.
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.
|
|
|
|
|
Luc Pattyn wrote: And I never understood the advantage, if any, of the banker's rounding.
The advantage is that in the long run it will round up just as many times as down. If you are doing millions of transactions, and the roundings doesn't even out in the end, you may loose a lot of money.
For us non-bankers, consistency makes more sense.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
I see. thanks.
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.
|
|
|
|
|
I am creating DataGridView dynamically could anybody tell me how to set
tab order for the same.
Truth Is The Simplest !!!!
|
|
|
|
|
tab order of DataGirdView!!!
AFAIK i know you are talking about column order of DGV, if yes then you can not change column order in one line, you need to delete all columns then add in the required order
Becoming Programmer...
|
|
|
|
|
i try the code,
<;asp:buttonfield buttontype="image" imageurl="~/Image/Blue hills.jpg" commandname="Select" />
but it accept single image .i want image folder or '<%# Eval("exe")%>'
|
|
|
|