+ -
当前位置:首页 → 问答吧 → 看IF方法怎样才能成立?

看IF方法怎样才能成立?

时间:2011-11-06

来源:互联网

Text1="8" Combo1="=" Text2="8" 
If Text1.Text & Combo1.Text & Text2.Text Then MsgBox "?????" 
以上代码我测试不成立
用什么办法可以实现此功能
请高手指教。

作者: andwdz   发布时间: 2011-11-06

在Text1和Text2填入数字,Text3填入关系(=、>、<、>=、<=、<>)
Text4输出比较结果

VB code

Private Sub Command1_Click()
  Dim tCheck As Boolean
  Dim tOutBool As Boolean
  tCheck = IsNumeric(Text1.Text) And IsNumeric(Text2.Text)
  If tCheck Then
    tOutBool = (InStr(Text3.Text, "=") And CLng(Text1.Text) = CLng(Text2.Text)) Or (InStr(Text3.Text, ">") And CLng(Text1.Text) > CLng(Text2.Text)) Or (InStr(Text3.Text, "<") And CLng(Text1.Text) < CLng(Text2.Text))
  End If
  Text4.Text = tOutBool
End Sub

作者: KiteGirl   发布时间: 2011-11-07