7,785
社区成员




Dim i As Integer
minValue = -(2 ^ (LenB(i) * 8 - 1))
maxValue = 2 ^ (LenB(i) * 8 - 1) - 1
MsgBox "Integer 的范围:" & minValue & "~" & maxValue
Dim l As Long
minValue = -(2 ^ (LenB(l) * 8 - 1))
maxValue = 2 ^ (LenB(l) * 8 - 1) - 1
MsgBox "long 的范围:" & minValue & "~" & maxValue
Private Sub Command1_Click()
Dim x As Integer
Debug.Print f(x)
Dim y As Long
Debug.Print f(y)
Dim z As Double
Debug.Print f(z)
End Sub
Private Function f(a) As String
Select Case VarType(a)
Case vbInteger
f = "-32,768 到 32,767"
Case vbLong
f = "-2,147,483,648 到 2,147,483,647"
Case vbDouble
f = "-1.79769313486232E308 到 -4.94065645841247E-324;正数时从4.94065645841247E-324 到 1.79769313486232E308"
'case ...
'case ...自已去查msdn吧。
'....
'...
End Select
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As Int16, b As Double
MsgBox(a.MaxValue & "~" & a.MinValue & "|" & b.MaxValue & "~" & b.MinValue)
End Sub