主题:求VB代码:如何做到在某文本框出现数值时自动附带上%
Private Sub Text1_Change(Index As Integer)
Style = "text-align:center;"
Text1(10).Text = Int((Text3(1).Text / Text1(8).Text) / 100) * 100
Dim z, a, b, c, d, e, f As Double
z = Val(Text3(1).Text)
a = Val(Text1(10).Text)
b = Val(Text1(8).Text)
c = Val(Text1(3).Text)
d = Val(Text1(4).Text)
e = Val(Text1(2).Text)
f = Val(Text1(0).Text)
If a = 0 Then Exit Sub
[color=FF0000]Text1(4).Text = Format(((c - b) / b) * 100, "0.0")[/color]
Text1(2).Text = Format(f - z)
Text1(0).Text = Format(c * a)
End Sub
我想在Text1(4).Text = Format(((c - b) / b) * 100, "0.0") 后面加上% ,让这个文本框的数值附带上%,能想到的都试了,比如format(数值表达式,"0.00%") 、Format(((c - b) / b) * 100, "0.0") & "%" 这些都试过了,都不成功!
下图是最终想达到的效果
[img]http://pic.yupoo.com/gu3669/B28Pf45Z/7hpIh.jpg[/img]
Style = "text-align:center;"
Text1(10).Text = Int((Text3(1).Text / Text1(8).Text) / 100) * 100
Dim z, a, b, c, d, e, f As Double
z = Val(Text3(1).Text)
a = Val(Text1(10).Text)
b = Val(Text1(8).Text)
c = Val(Text1(3).Text)
d = Val(Text1(4).Text)
e = Val(Text1(2).Text)
f = Val(Text1(0).Text)
If a = 0 Then Exit Sub
[color=FF0000]Text1(4).Text = Format(((c - b) / b) * 100, "0.0")[/color]
Text1(2).Text = Format(f - z)
Text1(0).Text = Format(c * a)
End Sub
我想在Text1(4).Text = Format(((c - b) / b) * 100, "0.0") 后面加上% ,让这个文本框的数值附带上%,能想到的都试了,比如format(数值表达式,"0.00%") 、Format(((c - b) / b) * 100, "0.0") & "%" 这些都试过了,都不成功!
下图是最终想达到的效果
[img]http://pic.yupoo.com/gu3669/B28Pf45Z/7hpIh.jpg[/img]