给定日期vb6的折扣百分比

时间:2017-07-21 15:18:24

标签: date vb6 percentage

我需要在vb6中编写代码

enter image description here

examble:

  

13“天” - 10%= 11“天”,16“小时”,48“分钟”

我试试这个:

1- i将天数转换为分钟

  

(13 * 24 * 60)= 18720

2

Dim Result As Double
Result = ((100 - 10) / 100) * 18720
Text3.Text = Result   '"text3.text=16848"

现在如何将结果格式化为DD HH NN? 致谢

1 个答案:

答案 0 :(得分:0)

像这样使用LEFT / MID / RIGHT关键字

Dim Result As Double
Dim Dayz, Hourz, MinuteZ As String
'
'Using your formula - which i have not checked
Result = ((100 - 10) / 100) * 18720
'
'extract values
Dayz = Left(Result,2)
Hourz = Mid(Result, 3, 2)
Minutez = Right(Result, 2)
'concatenate
Text3.Text = (Dayz & " Days, " & Hourz & " Hours, " & Minutez & " Minutes.")

您还可以查看FORMAT命令。