select案例与string

使用Select Case和一个string来比较,我感到沮丧。

我只需要检查是否有人发表评论,或只是通过扫描不同的对象。

所以我在声明中读到并检查是否有零件号码(总是以N开头),否则我知道下一步要去哪里。

由于有三种情况可能会发生下一个我不能拿一个if temp = Left(temp, 1) = "N"

我的错误在哪里?

  temp = Application.InputBox(Prompt:="Would you like to make a comment?" & vbCrLf & "If not please continue with next scan. ", Title:="Comment or go on", Type:=2) Select Case temp Case Is = Left(temp, 1) = "N" 'New scan - next number got scanned MsgBox ("Controlmessage - N Case") i = i + 1 .Cells(i, "D").Select temp = "" End Select 

尝试这个

 Sub Main() temp = Application.InputBox(Prompt:="Would you like to make a comment?" & vbCrLf & "If not please continue with next scan. ", Title:="Comment or go on", Type:=2) Select Case UCase(Left(temp, 1)) Case "N" MsgBox "N" Case "C" MsgBox "C" Case Else MsgBox "something else" End Select End Sub