2 Replies - 1886 Views - Last Post: 01 October 2012 - 09:57 PM Rate Topic: -----

#1 bemn67  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 16-September 12

Weird Error in not needed placed "Expression Expected"

Posted 01 October 2012 - 02:48 PM

Hi,I am a bit new to visual basic and I got the "Expression Expected" Error when I don't know why. Below is the line that I am getting the error.

If usernameInput == username And passwordInput == password Then
            Me.Visible = False
        End If

Is This A Good Question/Topic? 0
  • +

Replies To: Weird Error in not needed placed "Expression Expected"

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,480
  • Joined: 29-May 08

Re: Weird Error in not needed placed "Expression Expected"

Posted 01 October 2012 - 03:09 PM

== ha no meaning in vb.net = is what you need.

Dim b = 1 = 3
First one is assignment, the second is a comparison (typically assuming that the operator has been overloaded)

This post has been edited by AdamSpeight2008: 01 October 2012 - 03:23 PM

Was This Post Helpful? 2
  • +
  • -

#3 November-06  Icon User is offline

  • D.I.C Regular

Reputation: 46
  • View blog
  • Posts: 396
  • Joined: 04-January 11

Re: Weird Error in not needed placed "Expression Expected"

Posted 01 October 2012 - 09:57 PM

In C# and most languages, = is an assignment operator and == is used for comparison.

In VB.NET, you use = for both.

Just as AdamSpeight2008 said, you just need to replace ==, to = and everything should work fine.

There are differences in operators for C# and VB.NET so you have to study them.

' C#        VB.NET        Meaning
' !=        <>            Not Equal To
' ==        =             Equal To
' %         Mod           Modulus
' >         >             Greater Than
' <         <             Less Than
' >=        >=            Greater Than or Equal To
' <=        <=            Less Than or Equal To


These are the basics. I might not have included all. You can do more research on them.

This post has been edited by November-06: 01 October 2012 - 10:01 PM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1