值未以正确的格式设置 [英] Value not set in correct format

查看:83
本文介绍了值未以正确的格式设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我基本上反映了www.wonga.com贷款申请
到目前为止,一切都很好,但是当要生成利息和费用的值并将其放置在文本框中时,它会在金额上添加额外的0吗?总金额文本框是正确的,我尝试了所有我能想到的代码.

Hi Guys,

Im basically mirroring www.wonga.com loan application
So far so good, but when it comes to generate the values for the interest and fees and place them in a textbox it adds an additional 0 to the amount? the total amount textbox is correct, im tried everything i can think of my code is below.

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.TrackBar1.SetRange(0, 400)
        Me.TrackBar2.SetRange(0, 46)
    End Sub
    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll, TrackBar2.Scroll
        Me.TextBox1.Text = TrackBar1.Value
        Me.TextBox2.Text = TrackBar2.Value
        Me.TextBox3.Text = Me.TextBox1.Text
        Dim Dat As System.DateTime = Date.Now
        Dim Fee As Double = 5.56 ' ˆ
        Me.TextBox4.Text = Fee
        Dim Percent As Double = 360 '%
        Dim Borrow As Double = Me.TrackBar1.Value
        Dim CostPerAllDays As Double = ((Borrow * Percent / 100) / 360) * Me.TrackBar2.Value
        Me.TextBox4.Text = Format(CostPerAllDays, "£ 00.0") & Me.TrackBar2.Value
        Dim TotalCosts As Double = CostPerAllDays + Borrow + Fee
        Me.TextBox5.Text = Format(TotalCosts, "£ 00.00")
        Me.Label7.Text = Dat.AddDays(TrackBar2.Value).ToString("ddd MMM d yyyy")
    End Sub
End Class


如果我要将第一个轨迹栏最大化到400,然后将第二个轨迹栏最大化到45

借入的金额为400英镑,利息和费用为184.046英镑,总金额为589.56英镑

如您所见,总金额未正确累加,并且利息和费用中还有另一个0 ....

正如我一直在尝试各种格式,更改位只是为了卡在同一问题中一样,有人可以对此有所了解吗?.

在此先感谢您


If I was to maximize the 1st trackbar to 400 and then maximize the 2nd track bar to 45

the borrow amount would be £400 the interest and fees would be £ 184.046 and the total amount would be £ 589.56

As you can see the total amount doesnt add up correctly, and also there is another 0 in the interest and Fees....

Can some one shed any light on this, as i have been going around and around trying formats, changing bits just to be stuck in the same issue....

Thanks in advance

推荐答案

Did''nt,您在Microsoft论坛的vb论坛中提出了相同的问题.并且您在那里有问题的答案
Did''nt you ask the same question in vb forums on microsoft forums. and you had the answers to your problem there


不要使用Double类型.我遇到了问题 [ ^ ]与那我自己.

您对舍入/截断有什么要求?我认为,如果您使用format函数,它将截断数字.如果需要舍入,可以使用Math.Round函数,但是请确保舍入为零,除非您需要奇怪的银行舍入规则.

并选择一个命名约定并使用它...您的代码令人头疼. txtTotal比Textbox5更具可读性.
Don''t use the Double type. I ran into a problem[^] with that myself.

And what are your requirements for rounding/truncating? I think if you use the format function it truncates numbers. If you need to round you can use the Math.Round function but be sure to round away from zero unless you need the strange banking rounding rules.

And pick a naming convention and use it...your code is a giant headache. txtTotal is much more readable than Textbox5.


这篇关于值未以正确的格式设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆