How to display the part of an infinity value?

K

kimiraikkonen

Hello,
I have an aritmetic calculation like this:

First note that: i need a "timer" to get the value for value3.
(however removing "timer" didn't differ)

Dim value1 As Long
Dim value2 As String
Dim value3 As String
value3 = (value2 * 8) / value1
Label1.Text = value3

which returns result (label1.text) as an "infinity" value. If the
result is not infinity no problem.

Here's a problem that i want to display first 3 chars of the infinity
value?
(eg: if the infinity value is 180,5654568456845684.... i want
label1.text to display "180"

How can i do this?

Thanks...
 
A

Armin Zingler

kimiraikkonen said:
Hello,
I have an aritmetic calculation like this:

First note that: i need a "timer" to get the value for value3.
(however removing "timer" didn't differ)

Why do you mention a timer? Does it have any influence?
Dim value1 As Long
Dim value2 As String
Dim value3 As String
value3 = (value2 * 8) / value1
Label1.Text = value3

Always use Option Strict On. I can not even test your code.
which returns result (label1.text) as an "infinity" value. If the
result is not infinity no problem.

Here's a problem that i want to display first 3 chars of the
infinity value?
(eg: if the infinity value is 180,5654568456845684.... i want
label1.text to display "180"

Infinitiy is never 180,5.... Infinity is infinity and displayed by
"infinity".
How can i do this?

Don't divide by 0 and you wont' get "infinity".


Armin
 
A

Armin Zingler

kimiraikkonen said:
Hello,
I have an aritmetic calculation like this:

First note that: i need a "timer" to get the value for value3.
(however removing "timer" didn't differ)

Why do you mention a timer? Does it have any influence?
Dim value1 As Long
Dim value2 As String
Dim value3 As String
value3 = (value2 * 8) / value1
Label1.Text = value3

Always use Option Strict On. I can not even test your code.
which returns result (label1.text) as an "infinity" value. If the
result is not infinity no problem.

Here's a problem that i want to display first 3 chars of the
infinity value?
(eg: if the infinity value is 180,5654568456845684.... i want
label1.text to display "180"

Infinitiy is never 180,5.... Infinity is infinity and displayed by
"infinity".
How can i do this?

Don't divide by 0 and you wont' get "infinity".


Armin
 
A

Armin Zingler

Armin Zingler said:
Infinitiy is never 180,5.... Infinity is infinity and displayed by
"infinity".

Ah, you mean a finite number of decimal places....

Pass the correct format to the number's ToString function. If you had used
Option Strict, you would have been forced to think about this conversion.


Armin
 
A

Armin Zingler

Armin Zingler said:
Infinitiy is never 180,5.... Infinity is infinity and displayed by
"infinity".

Ah, you mean a finite number of decimal places....

Pass the correct format to the number's ToString function. If you had used
Option Strict, you would have been forced to think about this conversion.

Or, if you really want the first 3 characters, use the String's SubString
function.


Armin
 
K

kimiraikkonen

Ah, you mean a finite number of decimal places....

Pass the correct format to the number's ToString function. If you had used
Option Strict, you would have been forced to think about this conversion.

Armin

Yes, the problem occurs because of assigning zero to value3 field, but
after 0,5-1 seconds later value3 gets updated to a normal number like
250 (value3 as long, only integral part is shown, here's no problem)
due to my code configuration.

So, i need to calculate value1 after 1-2 seconds pass, thus value3
becomes normal and infinity will not be displayed how can i do that?
 
K

kimiraikkonen

Yes, the problem occurs because of assigning zero to value3 field, but
after 0,5-1 seconds later value3 gets updated to a normal number like
250 (value3 as long, only integral part is shown, here's no problem)
due to my code configuration.

Correcting previous post, problem was occuring due to assigning zero
to value1 field. Forget the rest of this paragraph.
So, i need to calculate value1 after 1-2 seconds pass, thus value3
becomes normal and infinity will not be displayed how can i do that?

OK, however i managed to make the code by adding this code block in a
timer (it queries value situation)
if not value1 = "0" then
'calculate value3
value3 = (value2 * 8) / value1
label1.text = value3

Now that the problem is i want to display first 3 chars(left to right
reading) of the value3. How can i trim or filter(throw away) the rest
of numberic part of value3?
 
K

kimiraikkonen

Yes, the problem occurs because of assigning zero to value3 field, but
after 0,5-1 seconds later value3 gets updated to a normal number like
250 (value3 as long, only integral part is shown, here's no problem)
due to my code configuration.

So, i need to calculate value1 after 1-2 seconds pass, thus value3
becomes normal and infinity will not be displayed how can i do that?

Correcting previous post, problem was occuring due to assigning zero
to value1 field. Forget the rest of this paragraph.
So, i need to calculate value1 after 1-2 seconds pass, thus value3
becomes normal and infinity will not be displayed how can i do that?

OK, however i managed to make the code by adding this code block in a
timer (it queries value situation)
if not value1 = "0" then
'calculate value3
value3 = (value2 * 8) / value1
label1.text = value3

Now that the problem is i want to display the integral part of the
value3. How can i trim or filter(throw away) the rest
of numberic part of value3? For ex: value3 = 185,986431654874984987498
= i want it as "185". (declared as string)
 
A

Armin Zingler

kimiraikkonen said:
Now that the problem is i want to display the integral part of the
value3. How can i trim or filter(throw away) the rest
of numberic part of value3? For ex: value3 =
185,986431654874984987498 = i want it as "185". (declared as string)

Int


Armin
 
A

Armin Zingler

kimiraikkonen said:
Now that the problem is i want to display first 3 chars(left to
right reading) of the value3. How can i trim or filter(throw away)
the rest of numberic part of value3?
185,986431654874984987498 = i want it as "185". (declared as string)

Int


Armin
 
A

Armin Zingler

kimiraikkonen said:
Correcting previous post, problem was occuring due to assigning zero
to value1 field. Forget the rest of this paragraph.

Could you please stop sending your text again and again? If you want to
correct something then only post the correction, not the whole post. Do you
expect us to compare all your postings to find out what you have changed?


Armin
 
K

kimiraikkonen

Could you please stop sending your text again and again? If you want to
correct something then only post the correction, not the whole post. Do you
expect us to compare all your postings to find out what you have changed?

Armin

Sorry, i'll try to categorize them and review better before post,
however you have some double posts, probably accidently.They're OK for
me, one of them that maybe you want to know.

http://img443.imageshack.us/img443/7357/dphp0.gif

Thanks.
 
A

Armin Zingler

kimiraikkonen said:
Sorry, i'll try to categorize them and review better before post,

Don't get me wrong, it's not a problem at all that you correct yourself, you
only shouldn't post /everything/ again but only the correction. Thanks!
however you have some double posts,

Surprise!


Armin
 
K

kimiraikkonen

Don't get me wrong, it's not a problem at all that you correct yourself, you
only shouldn't post /everything/ again but only the correction. Thanks!


Surprise!

Armin

No, problem, however i managed to solve the problem, the key was that
you pointed "infinity" warning occured because of trying to divide
value by zero, i added an "if" statement against division by zero,
however it's OK now.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top