tags:

views:

285

answers:

5

Hallo I,m developing a debt calculation program 'my problem is when i have to calculate the months to pay back the debt it comes to 28.04 and i have to get it to 29 can some one pls help me out. Thank you in advance

my code looks like this:

    Dim b, SubMtP As Integer
    Dim outsUm, si

    outsUm = TextBox1.Text

    SubMtP = Format(Val(TextBox1.Text) / Val(TextBox2.Text), "0.00")
    Math.Round(SubMtP + 1)
    TextBox5.Text = Format(Val(TextBox4.Text) / 12, "0.00")

    For i As Integer = 1 To SubMtP
+5  A: 

Use Math.Ceiling.

Pavel Minaev
A: 

Thanx for your reply i did try math.ceiling but i think i'm using the expression wrong,if you can look at my code and maybe c where i go wrong .

ty for your help.

+1  A: 

The line

Math.Round(SubMtP + 1)

does not do anything (has no side effects) since you aren't assinging or otherwise using the result.

If you are trying to get from 28.04 to 29 then you probably want Math.Ceiling. It's hard to tell what you are trying to do, but you probably want

SubMtP = Math.Ceiling(SubMtP);
Jason
+1  A: 

As Pavel said in the comment, you need to assign the result, and you should use Ceiling:

Dim result As Double = Math.Ceiling(SubMtP)

You are also strongly encouraged to switch Option Strict On everywhere in your code to enable strict, static type checking. This will result in a few compile errors in your above code that will need to be cleaned up. This is good because these code fragments are potential errors in your code and make it hard to maintain and to understand.

Konrad Rudolph
A: 

Ty all for your reply it was very helpful it solved my problem ,you guys and this site is grat

You should mark one of them as the answer.
Geoffrey Van Wyk
The Answer jason gave me worked "SubMtP = Math.Ceiling(SubMtP);"Hope this helps Geoffrey