Namespace and Import woes

J

Jim Andersen

I have a .Net 2.0 project called MyProj. I use VB.

In my appcode folder I have a .vb file (module1.vb) with different
functions I call from my forms (aspx-pages).

Module1.vb starts with some Imports and then
Namespace MyProj

and then comes the functions:
Public function AA()

In my forms CBF's I have
Partial Class frmYYY
Private sub Page_load......
X=MyProj.AA() ' because I put MyProj in front og AA it can locate AA

or, I can have
Namespace MyProj
and then
X=AA() ' without MyProj in front.

In one of my forms I have Imports MyProj instead.
And hten I dont need Namespace or putting MyProj in front of AA.

That looks good, so I wanted to do that in the other CBFs.
Removing the Namespace - line.

But it doesn't work?

If it says Me.OneControl.text=AA()
and I remove the Namespace - line, squiglys appear under the line.
If I put Imports MyProj the squiglys disappear from under AA, but
Me.OneControl squifly says: 'OneControl' is not a member of 'frmYYY'

Explanations ?

/jim

Jeg har et .Net 2.0 projekt der hedder MyProj. Jeg bruger VB.
I mit appcode bibliotek har jeg så en .vb fil (module1.vb) med en masse
forskellige funktioner jeg kalder inde fra mine formularer (aspx-sider).

Module1.vb starter med et par Imports og så
Namespace MyProj

og så kommer funktionerne fx
Public function AA()

I mine formularers CBFere kan jeg så skrive
Partial Class frmYYY
Private sub Page_load......
X=MyProj.AA() 'fordi jeg skriver MyProj foran AA kan den finde AA

eller jeg kan starte med at skrive
Namespace MyProj
og så ellers
X=AA() ' altså uden MyProj foran.

I én af formularerne har jeg istedet Imports MyProj
Og så behøves ikke namespace, og ejheller at skrive MyProj foran AA.

Det tiltalte min æstetiske sans, så det ville jeg også gøre i de andre
CBF'ere.
Altså fjerne den Namespace - linje
Men dér virker det ikke?
Hvis der står Me.EnKontrol.text=AA()
og jeg så fjerne Namespace - linjen, kommer der squiglys under hele linjen.
Hvis jeg så skriver Imports MyProj forsvinder squiglys under AA, men
Me.EnKontrol'en siger: 'EnKontrol' is not a member of 'frmYYY'

Hvad gør jeg galt ?

/jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top