|
Have a look at HttpRequest and HttpResponse; you don't always need a WebBrowser.
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.
|
|
|
|
|
Thanx for your reply but I'm almost a pro in using the WebRequest and WebResponse but the fact is that the WebRequest can help you in tracing for 1 step only and for example if there is a <img> tag in the HTML you should find it and request it manually, it is not a problem for simple tags like <img> but the fact is that I want to trace the requests from a Flash Player's object and even if I load the swf file using the WebRequest, I will not have the access to the requests and responses that goes out and comes in to the Flash Player so I need a complete web browser with the full request and response ability!
Sojaner!
|
|
|
|
|
I have the following code:
double numdaysPercentage;
numdaysPercentage = 14/30;
I get an answer like 0.0. I should get an answer like .4666667
Can someone tell me what I am doing wrong.
|
|
|
|
|
If you divide by an int, you get an int.
double n = 14/30.0;
will work
or
double n = 14/(double)30;
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
You are doing integer division, and 14/30 is indeed 0. On the other hand, 14.0/30 will give you what you are looking for.
Cheers,
Vikram.
The hands that help are holier than the lips that pray.
|
|
|
|
|
The suggestions above are good, you can also tag the numbers with an 'd' to indicate they are doubles. (Or 'f' for floats)
double n = 14d / 30d;
Simon
|
|
|
|
|
hello,
im having problem with the conversion from string to float, it works good when there is no character in string, for example :
string a = "1.22235647228796";
string b = "8.742277657e-008";
float a = Convert.ToSingle(a);
float b = Convert.ToSingle(b);
the first conversion will work but second will give error that "string was not is correct format"
any idea to solve it ?
thanks
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Always use float.TryParse for a start, so you don't get an exception. Not sure how you specify to accept that format, tho.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: Always use float.TryParse for a start
Not always. Sometimes an exception, due to a missed return value check, is in order. I would prefer an exception in certain instances.
Pits fall into Chuck Norris.
|
|
|
|
|
i didnt specify, when i read single from a file it automatically came, eg
BR.ReadSingle()
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Try using the NumberStyles enum in the System.Globalization namespace to parse that text.
float b = float.Parse(ExpNumString, NumberStyles.AllowExponent|NumberStyles.Float);
|
|
|
|
|
Hi all,
In my app i have 1 class call sqlconnection which is use for get/update db data. I am use this class to get dataset and after i edit the dataset i will pass back to this class and update it.Example, call sqlconnection method from formA to get and update database:
class sqlconnection:
private OleDbConnection objConn;<br />
private OleDbDataAdapter objAdapter = new OleDbDataAdapter();<br />
<br />
public void DbConnection()<br />
{<br />
objConn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=Userprogram.mdb");<br />
}<br />
<br />
public DataSet SelectSQL(String stable,String sProgramName)<br />
{<br />
DataSet ds=new DataSet();<br />
objConn.Open();<br />
objCmdSelecte = new OleDbCommand("Select * From Timeway where TW_Program_Name ='" + sProgramName + "'", objConn);<br />
<br />
objAdapter.SelectCommand = objCmdSelecte;<br />
objAdapter.Fill(ds);<br />
objConn.Close();<br />
return ds;<br />
}<br />
<br />
public void UpdateSQL(DataSet ds)<br />
{<br />
objConn.Open();<br />
objAdapter.Update(ds);<br />
objConn.Close();<br />
}
formA:
sqlconn.DbConnection();<br />
ds = sqlconn.SelectSQL("PS", "Program Ni");<br />
for (int i = 0; i < 16;i++ )<br />
{<br />
ArrayData[i] = ArrayTextbox[i].Text;
ds.Tables[0].Rows[0][i + 1] = ArrayData[i];<br />
}<br />
ds.AcceptChanges();<br />
sqlconn.UpdateSQL(ds);
The problem i am facing is , nothing change to my database.I have already check the dataset which is pass to my sqlconnection class and it have been modified. So what i guess is the problem of objAdapter.update . Can anyone guide me to solve this problem?
thanks in advance
cocoon
|
|
|
|
|
Hi all,
Thank you for those who are read through my question. I have found the solution , very simple, that is add a tablemapping.add() before fill and acceptchanges() and the end when update record.
regard
cocoon
|
|
|
|
|
Hello All,
How to compare two enum types?
Thanks
|
|
|
|
|
If you need to, then you should probably use the one enum in both cases.
you have two options:
1 - cast both to int, if you can make the int values correlate ( but then just use the one enum )
2 - write a method that applies whatever comparison rules you need, by hand.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
use the typeof(ur enum) with compare() method
|
|
|
|
|
How would that work, exactly ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Good question
i have put small exmaple here
public enum Named : int
{
A,
B,
C,
D
}
public enum Names : byte
{
A,
B,
C,
D
}
check
if (Enum.Equals(typeof(Named),typeof(Names)))
{
//type is equal
}
thanks you
|
|
|
|
|
OK - so does that compare based on enum name, or their intrinsic int value ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I seen your profile,your are MVP in code project, Are you checking me?
Basically Compare based on the type of the enum
You can understand from my example.
Thank you
|
|
|
|
|
No, I've never seen this before, I would think that comparing two different enums is a bad design, I'm curious how it would work.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
So
is it wrong? or is it can't be exist like that?
|
|
|
|
|
I am saying I've never used it, I was curious how it works, although I'd never use it, personally.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
You're trying to compare the types to each other. The enum Equals takes two enum values.
www.wickedorange.com
www.andrewvos.com
|
|
|
|