Last post Aug 24, 2009 02:51 PM by paladinckm
Aug 19, 2009 09:00 AM|paladinckm|LINK
I have a function where I have to add two values (declared as string) on two different pages, So Iam bringing one value from one page to the second page where I have second value and adding both of them to display the result in a label. But
I am not able to do that. eg: 1st value is 4.20 ( both values are time in seconds) and 2nd value is 0.34 then I want the result as 4.54( instead I am gettign the result as 188.8.131.52 , So can anyone tell me how to add these two ..My code is attached.
Dim L1 As String
L1 = main.TimeElapse(Value1).ToString
'Label1.Text value is the below line
Status.ShowSuccess("Ready: Result is " + _Myfunction.GetTimeInSeconds.ToString("N1") + TimeElapse(value1).GetTimeInSeconds.ToString("N2") + " seconds")
visual basic.NET 2005
Aug 19, 2009 12:10 PM|DrivenTooFar|LINK
If you are trying to do math with strings, then you will need to convert them first. In this case, converting to a double is probably your best bet. You may want to create another function to help you with this but the most direct way to go about it would
be like this:
Status.ShowSuccess("Ready: Result is " & Convert.ToString(Convert.ToDouble(_Myfunction.GetTimeInSeconds.ToString("N1")) + Convert.ToDouble(TimeElapse(value1).GetTimeInSeconds.ToString("N2"))) & " seconds")
Aug 20, 2009 04:58 PM|paladinckm|LINK
Thanks for your reply!!
I have tired your code as mentioned , but I get the error Message
"Conversion from String "seconds" to type 'Double' is not valid
Input string was not in correct format.
As I have mentioned I am trying to capture the time taken in seconds. I have tired changing the code but nothing worked for me.
Aug 20, 2009 05:17 PM|RatheeshC|LINK
Dim db1 As Double = Double.Parse(_Myfunction.GetTimeInSeconds.ToString("N1"))
Dim db2 As Double = Double.Parse(TimeElapse(value1).GetTimeInSeconds.ToString("N2"))
Dim Result As String = Convert.ToString(db1 + db2)
Now result will contain 4.54
Aug 24, 2009 02:51 PM|paladinckm|LINK
Hello and Thanks to both of you for you replies ,
I have changed few changes to the intial idea and code given and it worked. Ratheesh, your code is working too..
"Ready: Login Completed in " + (Convert.ToDouble(_myFunction.GetTimeInSeconds.ToString("N1")) + Convert.ToDouble(TimeElapse(Value1).GetTimeInSeconds.ToString("N2"))).ToString() + " seconds")