VB编码问题

时间:2013-11-13 16:12:07

标签: vb.net vba

我有以下查询,我无法运行。

任何人都可以建议我的其他人的正确顺序以及是否因为我看不到它?

我的查询是......

select case sourcefields("Query8111.Job Code and Stage")


Case"703"
currentfield = "T703"
Case"801"
currentfield = "T801"

case else 
if right(rtrim(sourcefields("Query8111.Job Code and Stage")),4) = "-99C" then 
currentfield = "T020"
ElseIf
right(rtrim(sourcefields("Query8111.Job Code and Stage")),3) = "EXT" then 
currentfield = "T015"
else
currentfield = "T010"

end if
end select

我的错误信息是: -

enter image description here

所有帮助赞赏

2 个答案:

答案 0 :(得分:1)

自从我使用VB以来很长一段时间,这是你需要的吗?

Dim Q As String
Q = RTrim(sourcefields("Query8111.Job Code and Stage"))   

Select Case Q
Case "703"
currentfield = "T703"
Case "801"
currentfield = "T801"
Case Else
    If Right(Q, 4) = "-99C" Then
    currentfield = "T020"
    Else
        If Right(Q, 3) = "EXT" Then
        currentfield = "T015"
        Else
        currentfield = "T010"
        End If
    End If
End Select

答案 1 :(得分:0)

我认为你的ElseIf错了。条件语句在同一行。我认为你的意思是Strings.Right,而不是right

Select Case sourcefields("Query8111.Job Code and Stage")

Case"703"
    currentfield = "T703"
Case"801"
    currentfield = "T801"

Case Else
    If Strings.Right(rtrim(sourcefields("Query8111.Job Code and Stage")),4) = "-99C" then 
         currentfield = "T020"
    ElseIf Strings.Right(rtrim(sourcefields("Query8111.Job Code and Stage")),3) = "EXT" then 
         currentfield = "T015"
    Else
         currentfield = "T010"    
    End If
End Select