By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,908 Members | 2,056 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,908 IT Pros & Developers. It's quick & easy.

"Imports Microsoft.VisualBasic" doesn't import

P: n/a
I've built a control. At the top of my control, I have this:

Imports Microsoft.VisualBasic

Then, later, I call a function like this:

DateTime.Now.Year.ToString()

This works fine on my machine. My coworker takes the exact same file,
compiles it, and gets errors until he explicitly writes out the function as:
microsoft.VisualBasic.DateAndTime.Now.Year.ToStrin g()

Why?

This has happened before and only seems to affact the microsoft.VisualBasic
namespace. On his computer, it just doesn't seem to import it.

-Darrel
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Wed, 18 Aug 2004 17:30:58 -0500, "darrel" <no*****@hotmail.com>
wrote:

microsoft.VisualBasic.DateAndTime.Now.Year.ToStri ng()

Why?
DateTime is a System.ValueType
This has happened before and only seems to affact the microsoft.VisualBasic
namespace. On his computer, it just doesn't seem to import it.


He'd also have to use a M instead of a m for it to work. Are you
using this name space for anything in particular cause I don't think
you need it in most cases.

-Adam
Nov 18 '05 #2

P: n/a
The frameowk is probably getting confused because that function doesn't
require the VisualBasic library at all. You can say the exact same thing
with System.DateTime.Now.Year.ToString(). If the System and
Microsoft.VisualBasic namespaces are both imported, how does the
DateTime.Now.Year.ToString() code know which namespace you are referencing?
It doesn't, which is why it generates the error unless the VisualBasic
namespace is specified as then there isn't any confusion by the compiler.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"darrel" <no*****@hotmail.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
I've built a control. At the top of my control, I have this:

Imports Microsoft.VisualBasic

Then, later, I call a function like this:

DateTime.Now.Year.ToString()

This works fine on my machine. My coworker takes the exact same file,
compiles it, and gets errors until he explicitly writes out the function
as:
microsoft.VisualBasic.DateAndTime.Now.Year.ToStrin g()

Why?

This has happened before and only seems to affact the
microsoft.VisualBasic
namespace. On his computer, it just doesn't seem to import it.

-Darrel

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.