# Dim Variable As Double

I am dimesioning a variable as a double because I need to store a floating point number but when I store the number it just store the integer part only. Why?

ie:

Dim tmpProgress As Double
tmpProgress = 100/6

ans then tmpProgress will = 17

What should I do?
###### Who is Participating?

Commented:
If your Progressbar.Max = 100 then use code like this:

Dim tmpProgress As integer= CInt(CDbl(Step)/CDbl(Total) * 100)

where Step is the number of steps you've executed and Total is the total number of steps you need to execute.
0

Middle School Assistant TeacherCommented:

tmpProgress = 100.0 / 6.0
tmpProgress = CDbl(100) / CDbl(6)
0

Commented:
Try the following...the reason is that VB.NET thinks that the number 100 is an integer and the number 6 is an integer so when it divides them you should get an integer.

Dim d As Double
d = 100.0 / 6.0
Console.WriteLine(d.ToString())

If that is not working...make sure you are not performing any other operations on it.

Later,
Eric
0

Author Commented:
Well, actually what I'm doing is using a progressbar.value to complete the 100% for a database load, but it seems that progressbar.value accept only int values.
0

Author Commented:
What do you mean with the number of steps I've executed?
0

Commented:
I think he is talking about "percentage complete".

I.E.~ if you have 10 total steps and you have completed 5.  If you plug that into his equation you will get 50%.

Later,
Eric
0

Commented:
Mylor, thanks for the points.  As for the B grade, I would suggest that I thought the question was answered thoroughly enough.  Mind if I ask what we should have done to receive an "A" grade?

http://www.experts-exchange.com/help.jsp#hi73
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.