[英]What is the equivalent of “!=” in Excel VBA?
問題是!=
在excel vba中不起作用。
我希望能夠使用
If strTest != "" Then
代替If strTest = "" Then
還有另一種做法嗎? !=
?
我模仿的功能!=
是
Sub test()
Dim intTest As Integer
Dim strTest As String
intTest = 5
strTest = CStr(intTest) ' convert
Range("A" + strTest) = "5"
For i = 1 To 10
Cells(i, 1) = i
If strTest = "" Then
Cells(i, 1) = i
End If
Next i
End Sub
因為VBA中的不等運算符是<>
If strTest <> "" Then
.....
operator !=
用於C#,C ++。
在VBA中, !=
運算符是Not
運算符,如下所示:
If Not strTest = "" Then ...
只是一張紙條。 如果要將字符串與""
進行比較,在您的情況下,請使用
If LEN(str) > 0 Then
甚至只是
If LEN(str) Then
代替。
嘗試使用<>
而不是!=
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.