vb compile error

Ronald Chandler 41 Reputation points
2022-11-18T20:35:32.793+00:00

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?

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

1 answer

Sort by: Most helpful
  1. Viorel 111.7K Reputation points
    2022-11-18T20:48:33.32+00:00

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