Be Aware, It’s Not C!

Be Aware, It’s Not C!

VB developers that program with C language might be confused by a feature in the language. Consider thiscode:

 Dim x As IntegerDim y As IntegerDim z As Integer     x = 10y = 20z = 0     ''''Assume function max returns the maximum ''''of  the twoif  (z = max(x, y)) > 0 then         Msgbox CStr(z)Else        Msgbox "How Come?"End if

In the code, you would expect the message box to display 20, as it would do in C. VB, however, comparesz with the RHS (right-hand side) even before the assignment, irrespective of the brackets. Be careful.


About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist