vb compile error

Ronald Chandler 41 Reputation points

I am using Visual Studio Express 2013 and Visual Basic., Windows 10. The statement:
NetworkCredential MyCredentials = New NetworkCredential("username", "password")
will not compile. Error is "NetworkCredential is a type and cannot be used as an expression"
My imports are:
Imports System.Net.Mail
Imports System.Net.Mime
Imports System.Net
What am I missing?

An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,106 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 95,071 Reputation points

    Try Dim MyCredentials = New NetworkCredential("username", "password") or Dim MyCredentials As NetworkCredential = New NetworkCredential("username", "password").