发布网友 发布时间:2023-01-01 21:57
共2个回答
热心网友 时间:2023-10-30 21:08
1、'usd = Int(rmb / fx * 100 + 0.5) / 100这和取两位小数,四舍五入有关系吗?追答Private Sub Command1_Click()
'错误1
'定义函数格式出错,将
'Dim usd As Double, rmb As Double, fx As Double
'改成
'Dim usd As Long, rmb As Long, fx As Long
'错误2
'因除数不能为 0 否则会出错
'需要加上判断语句判断fx是否为 0
'修改后代码如下
Dim usd As Long, rmb As Long, fx As Long
rmb = Val(Text1.Text)
fx = Val(Text2.Text)
If fx 0 Then
usd = Int(rmb / fx * 100 + 0.5) / 100
Text3.Text = Str(usd)
Else
Text3.Text = "除数不能等于0"
Text2.SetFocus '得到焦点
End If
End Sub
'任务中,请采纳!谢谢!
热心网友 时间:2023-10-30 21:08
好象是填USD吧.前面已把USD按要求求出来了.转成字符型数据即可.