1

如何在 vb.net 的一个语句中声明两个对象?例子

If IsNumeric(TextBox1.Text),(TextBox2.Text) Then
lbl_answer.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
Else
MsgBox("只能计算错误数字")
End If

我可以

如果不是数字(textbox1.text)那么

但我不能说

如果不是数字(textbox1.text),(textbox2.text)

我该怎么做?

4

1 回答 1

2

由于到目前为止没有人这样做,让我表达您的选择(直接来自评论 - 抱歉,为什么这些不是我不知道的答案):

  1. And

    If IsNumeric(TextBox1.Text) And IsNumeric(TextBox2.Text) Then ...
    
  2. AndAlso(细微的区别:AndAlso如果第一个表达式的计算结果为假,则不要计算第二个表达式)

    If IsNumeric(TextBox1.Text) AndAlso IsNumeric(TextBox2.Text) Then ...
    

我不认为 LINQ 真的是一种选择。

于 2012-04-18T12:00:15.620 回答