I was wondering if I can import a single function like python without importing all the other things like python does:
from prog1 import func
答案 0 :(得分:1)
In VB you need to do two things to able to use a function or anything else declared in another assembly or namespace.
Imports System.Drawing
.Then you can use all the things in there.
Instead of using an Imports
statement you can also specify the namespace directly. Example:
'Without Imports
Dim image As System.Drawing.Image
image = New System.Drawing.Bitmap(myImagefile)
With Imports System.Drawing
at the top of the code:
Dim image As Image
image = New Bitmap(myImagefile)
The most important assemblies are already referenced and the most often used namespaces imported implicitly. These namespaces are list in the project properties under References.
Note that you cannot import single functions, you always have to reference a whole assembly. The Imports
does not influence the resources used. It only makes it handier to access things. They reduce typing.
Note also, that the standard .NET libraries of the .NET Framework are installed on the system and are already compiled. They are not imported physically into your project, they are only referenced. I.e., using them does not make your application bigger.