贪玩网页游戏平台:一个vb问题

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 03:39:53
为什么我用sinx算出值,计算机输出后,比如0.12454,怎么只有.12454了?怎么把那个0弄出来?

那是VB数值数据格式所定,如显示则需转换成字符串来处理,见如下代码:
Option Explicit
Dim n As Double
Dim a As Double
Dim b As String

Private Sub Command1_Click()
a = Val(Text1)
If a < 1 And a > 0 Then
b = "0" & a
Text2 = b
ElseIf a > -1 And a < 0 Then
n = Len(a)
b = "-0" & Mid(a, 2, n - 2)
Text2 = b
Else
b = a
Text2 = b
End If
End Sub

Private Sub Form_Load()
Text1 = ""
Text2 = ""
End Sub