module1.bas

来自「计算器,和windows系统的相似的一个计算器」· BAS 代码 · 共 42 行

BAS
42
字号
Attribute VB_Name = "Module1"
Function fun(ByVal a As Double, ByVal i As Integer, ByVal flag As Integer)
  s = Str(a)
  pos = InStr(1, s, ".", vbBinaryCompare)
  If pos = 0 And flag = 1 Then
     s = s + "." + Str(i)
     a = Val(s)
  End If
  If pos = 0 And flag = 0 Then
      a = a * 10 + i
  End If
  If pos <> 0 Then
     s = s + Str(i)
     a = Val(s)
  End If
  fun = a
End Function

Function comput(ByVal a As Double, ByVal b As Double, index As Integer)
Select Case index
     Case 0: result = a / b
     Case 1: result = a * b
     Case 2: result = a - b
     Case 3: result = a + b
     Case 4: result = a Mod b
End Select
comput = result
End Function

Function convert(ByVal a As Double)
  s = Str(a)
  pos = InStr(1, s, "E", vbBinaryCompare)
  If a > -1 And a < 1 And a <> 0 And pos = 0 Then
     s = "0" + s
  End If
  pos = InStr(1, s, ".", vbBinaryCompare)
  If pos = 0 Then
     s = s + "."
  End If
  convert = s
End Function

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?