- 帖子
- 97
- 主題
- 32
- 精華
- 0
- 積分
- 167
- 點名
- 0
- 作業系統
- WinXP
- 軟體版本
- Office2003
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2011-3-22
- 最後登錄
- 2017-8-16
|
多謝大大,讓我對這方面有新的見解
我有試另外一個方法可以減少code size
程式寫法大概像下面這樣:利用2^X 來判斷
If Mid(Cells(4, 10), 1, 1) = "U" Then
Select Case Mid(Cells(4, 10), 2, 1)
Case Is = 1
bit = 8
Case Is = 2
bit = 16
Case Is = 3
bit = 24
Case Is = 4
bit = 32
End Select
max1 = 2 ^ bit - 1
min1 = 0
Cells(4, 17).Value = min1 & "~" & max1
If Cells(4, 15) > min1 Then
min1 = Cells(4, 15)
End If
If Cells(4, 16) < max1 Then
max1 = Cells(4, 16)
End If
Cells(4, 18).Value = min1 & "~" & max1
ElseIf Mid(Cells(4, 10), 1, 1) = "S" Then
Select Case Mid(Cells(4, 10), 2, 1)
Case Is = 1
bit = 7
Case Is = 2
bit = 15
Case Is = 3
bit = 23
Case Is = 4
bit = 31
End Select
max1 = 2 ^ bit - 1
min1 = 1 - 2 ^ bit
Cells(4, 17).Value = min1 & "~" & max1
If Cells(4, 15) > min1 Then
min1 = Cells(4, 15)
End If
If Cells(4, 16) < max1 Then
max1 = Cells(4, 16)
End If
Cells(4, 18).Value = min1 & "~" & max1
End If
Next |
|