Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 428
  • Last Modified:

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?
0
Mylor
Asked:
Mylor
  • 2
  • 2
  • 2
  • +1
2 Solutions
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Use one of these instead:

        tmpProgress = 100.0 / 6.0
        tmpProgress = CDbl(100) / CDbl(6)
0
 
RealMrTeaCommented:
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
 
MylorAuthor 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
PaulHewsCommented:
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
 
MylorAuthor Commented:
What do you mean with the number of steps I've executed?
0
 
RealMrTeaCommented:
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
 
PaulHewsCommented:
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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now