Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba IIf在IIf内分配变量值_Vba_Ms Access - Fatal编程技术网

Vba IIf在IIf内分配变量值

Vba IIf在IIf内分配变量值,vba,ms-access,Vba,Ms Access,我试图理解为什么我不能用IIf来给变量赋值 dim i as integer dim j as integer i = 1 j = 2 if i = 1 or iif(j = i, j = 10, j = 20) then msgbox j end if 我知道我可以使用IIf来分配如下变量: j = IIf(1 = 2, 5, 10) 在这种情况下,j等于10。解决方法如下: Dim i As Integer i = 1 Dim j As Integer j = 2 Sel

我试图理解为什么我不能用IIf来给变量赋值

dim i as integer
dim j as integer

i = 1
j = 2

if i = 1 or iif(j = i, j = 10, j = 20) then
    msgbox j
end if
我知道我可以使用IIf来分配如下变量:

j = IIf(1 = 2, 5, 10)

在这种情况下,j等于10。

解决方法如下:

Dim i As Integer
i = 1

Dim j As Integer
j = 2

Select Case i
    Case 1
        'Do nothing
    Case j
        j = 10
    Case Else
        j = 20
End Select

MsgBox j

IIf不是这样的,也不是有意的。研究这个问题。