在数据库的表里有一个字段是varchar类型,用vb做个界面输入,要求输入必须为f/m,所以我写成如下:if text1.text <> "f" or text1.text <> "F" or text1.text <> "m" or text1.text <> "M" then
   response = MsgBox("有数据项为空,请重新输入!", vbYesNo + 32, "输入错误")
           If response = vbYes Then
              Form1.Show
              text1.setfocus
            End If
else
   adocon.Execute(....)
End if
可是运行结果却是即使text文本框里输入为f/m,还是出现msgbox对话框,而不执行
adocon.Execute(....),请问这段代码哪儿出问题了.thanks a lot!

解决方案 »

  1.   

    If InStr(LCase(Text1.Text), "f") = 0 And InStr(LCase(Text1.Text), "m") = 0 Then
            MsgBox "空"
        End If
      

  2.   

    If (Text1.Text <> "f") And (Text1.Text <> "F") And (Text1.Text <> "m") And (Text1.Text <> "M") Then
       response = MsgBox("有数据项为空,请重新输入!", vbYesNo + 32, "输入错误")
               If response = vbYes Then
                  Form1.Show
                  Text1.SetFocus
                End If
    Else
       'adocon.Execute(....)
    End If
    你的逻辑判断错了,OR是或者,AND是而且
    你前面写的,当是F时,或者到一个M,错误,当是M时,或者到一个F,也是错误,所以不会到下面的语句来