What is the equivalent of "!=" in Excel VBA?

What'sUP picture What'sUP · Jul 21, 2012 · Viewed 396.7k times · Source

The problem is that != does not work as a function in excel vba.

I want to be able to use

If strTest != "" Then instead of If strTest = "" Then

Is there another approach to do this besides !=?

My function to mimic != is

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

Answer

Steve picture Steve · Jul 21, 2012

Because the inequality operator in VBA is <>

If strTest <> "" Then
    .....

the operator != is used in C#, C++.