473,503 Members | 4,692 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using vb control

I have been given a tiny little vb control that I would like to use in my c#
application. I don't want to make an independant .dll out of it because
it's so small. Can anyone tell me how I can include it in my visual studio
..net project and have it properly compiled as VB ?
Nov 16 '05 #1
16 1381
Hi Mike,

Based on my understanding, you want to use your VB control in .Net project.

I think your Vb control is an Active X control, which is also a COM
component. In .Net, you can use COM through COM interop.

In VS.net, you can just use "Add Reference" to browse to the VB control and
add it into. Then VS.net will automatically add a .Net class wrapper for
your COM component.

Then you can use it like .Net class. For more detail information and class
information about your wrapped VB control, you can see its reference in
"Object Browser"

==================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #2
I guess I didn't describe my problem very well. I have been given two
files, one that is is a .vb file which implements user control, written in
VB.NET and the other is the complementory .resx file. I would like to
compile these into my c# project, but within that project the compiler
doesn't seem to recognize VB. How can I successfully add these files into
my otherwise c# project and get the compiler to know what to do. I'm rather
suprized it's not completely automatic.
""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:Yo*************@cpmsftngxa10.phx.gbl...
Hi Mike,

Based on my understanding, you want to use your VB control in .Net project.
I think your Vb control is an Active X control, which is also a COM
component. In .Net, you can use COM through COM interop.

In VS.net, you can just use "Add Reference" to browse to the VB control and add it into. Then VS.net will automatically add a .Net class wrapper for
your COM component.

Then you can use it like .Net class. For more detail information and class
information about your wrapped VB control, you can see its reference in
"Object Browser"

==================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #3
Hi Mike,

Thanks very much for your feedback.

Oh, based on your feedback, I see that what you have is a VB.net
usercontrol's source file. You want to use it in a C# project.

For a C# project, it will use csc.exe compiler to compile it and generate
assembly. It can not recognize VB.net code.

You should add a new VB.net windows control project into your entire
Solution, then add the VB.net usercontrol source code into this project.
Then, you can compile this project, an assembly will generate for this
VB.net usercontrol source code.

At last, you may add this usercontrol assembly into C# project through Add
Reference or through Tool Box

===================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #4
I guess what I'm hearing is that with .NET it is not possible to mix c# code
with vb code in a single .dll.

""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:r9*************@cpmsftngxa10.phx.gbl...
Hi Mike,

Thanks very much for your feedback.

Oh, based on your feedback, I see that what you have is a VB.net
usercontrol's source file. You want to use it in a C# project.

For a C# project, it will use csc.exe compiler to compile it and generate
assembly. It can not recognize VB.net code.

You should add a new VB.net windows control project into your entire
Solution, then add the VB.net usercontrol source code into this project.
Then, you can compile this project, an assembly will generate for this
VB.net usercontrol source code.

At last, you may add this usercontrol assembly into C# project through Add
Reference or through Tool Box

===================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #5
Mike Oliszewski <mi***@faxback.com> wrote:
I guess what I'm hearing is that with .NET it is not possible to mix c# code
with vb code in a single .dll.


Yes it is - just not from VS.NET. From the command line, you can
compile to .netmodule files, and then use the assembly linker to link
those together into a single assembly.

It's rarely worth the hassle though.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #6
Allright Jon! Is there any way you could give us the
exact method of actually doing this? I have tried so
many different ways to do this, it isn't even funny
anymore. Someone else told me this was possible,
but I suspect he had not actually tried it. Please, if
it can really be done, post an example of the series
of commands so that I can really do it for myself.

I have resorted to decompiling to IL, then merging
the resulting code from the VB and C# into one IL
file, then compiling that with ILASM to make one
assembly. Please, PLEASE do not just quote the docs
on this, I want to know that someone has done it
and that everything works as it is supposed to.

I'm serious, I am now wondering if this is really
possible. I'm talking about making ONE executable
assembly, not just linking to an existing netmodule.
For the life of me, I cannot get this to work.
One assembly that does NOT require any other files
or modules or assemblies to be present. Can it be
done?

Thanks.

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Mike Oliszewski <mi***@faxback.com> wrote:
I guess what I'm hearing is that with .NET it is not possible to mix c# code with vb code in a single .dll.


Yes it is - just not from VS.NET. From the command line, you can
compile to .netmodule files, and then use the assembly linker to link
those together into a single assembly.

It's rarely worth the hassle though.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Nov 16 '05 #7
Allright Jon! Is there any way you could give us the
exact method of actually doing this? I have tried so
many different ways to do this, it isn't even funny
anymore. Someone else told me this was possible,
but I suspect he had not actually tried it. Please, if
it can really be done, post an example of the series
of commands so that I can really do it for myself.

I have resorted to decompiling to IL, then merging
the resulting code from the VB and C# into one IL
file, then compiling that with ILASM to make one
assembly. Please, PLEASE do not just quote the docs
on this, I want to know that someone has done it
and that everything works as it is supposed to.

I'm serious, I am now wondering if this is really
possible. I'm talking about making ONE executable
assembly, not just linking to an existing netmodule.
For the life of me, I cannot get this to work.
One assembly that does NOT require any other files
or modules or assemblies to be present. Can it be
done?

Thanks.

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Mike Oliszewski <mi***@faxback.com> wrote:
I guess what I'm hearing is that with .NET it is not possible to mix c# code with vb code in a single .dll.


Yes it is - just not from VS.NET. From the command line, you can
compile to .netmodule files, and then use the assembly linker to link
those together into a single assembly.

It's rarely worth the hassle though.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Nov 16 '05 #8
Allright Jon! Is there any way you could give us the
exact method of actually doing this? I have tried so
many different ways to do this, it isn't even funny
anymore. Someone else told me this was possible,
but I suspect he had not actually tried it. Please, if
it can really be done, post an example of the series
of commands so that I can really do it for myself.

I have resorted to decompiling to IL, then merging
the resulting code from the VB and C# into one IL
file, then compiling that with ILASM to make one
assembly. Please, PLEASE do not just quote the docs
on this, I want to know that someone has done it
and that everything works as it is supposed to.

I'm serious, I am now wondering if this is really
possible. I'm talking about making ONE executable
assembly, not just linking to an existing netmodule.
For the life of me, I cannot get this to work.
One assembly that does NOT require any other files
or modules or assemblies to be present. Can it be
done?

Thanks.

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Mike Oliszewski <mi***@faxback.com> wrote:
I guess what I'm hearing is that with .NET it is not possible to mix c# code with vb code in a single .dll.


Yes it is - just not from VS.NET. From the command line, you can
compile to .netmodule files, and then use the assembly linker to link
those together into a single assembly.

It's rarely worth the hassle though.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Nov 16 '05 #9
Allright Jon! Is there any way you could give us the
exact method of actually doing this? I have tried so
many different ways to do this, it isn't even funny
anymore. Someone else told me this was possible,
but I suspect he had not actually tried it. Please, if
it can really be done, post an example of the series
of commands so that I can really do it for myself.

I have resorted to decompiling to IL, then merging
the resulting code from the VB and C# into one IL
file, then compiling that with ILASM to make one
assembly. Please, PLEASE do not just quote the docs
on this, I want to know that someone has done it
and that everything works as it is supposed to.

I'll be watching...

Thanks.

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Mike Oliszewski <mi***@faxback.com> wrote:
I guess what I'm hearing is that with .NET it is not possible to mix c# code with vb code in a single .dll.


Yes it is - just not from VS.NET. From the command line, you can
compile to .netmodule files, and then use the assembly linker to link
those together into a single assembly.

It's rarely worth the hassle though.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #10
Gary Morris <gw*******@hotpop.com> wrote:
I'm serious, I am now wondering if this is really
possible. I'm talking about making ONE executable
assembly, not just linking to an existing netmodule.
For the life of me, I cannot get this to work.
One assembly that does NOT require any other files
or modules or assemblies to be present. Can it be
done?


Ah, an assembly in a single file - no, I don't think *that's* possible
with the standard tools.

Using .netmodule files *is* creating a single assembly, but it's an
assembly spread out over multiple files.

It should be theoretically possible to merge a bunch of .netmodules
into a single file, but I don't know of any tools to do it...

<sfx: tappety tappety>

Now I do. If you go to

http://www.gotdotnet.com/Community/UserSamples/

and search for illink, you should find what you're after. I haven't
tried it, so can't vouch for it working or anything.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #11
Thanks. I'll check it out. From the post it sounded like you
had actually done this. Sorry about the multiple posts, my
server was acting strange and telling me that it could not
send the post, so I kept trying. Obviously it was lying to
me!

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Gary Morris <gw*******@hotpop.com> wrote:
I'm serious, I am now wondering if this is really
possible. I'm talking about making ONE executable
assembly, not just linking to an existing netmodule.
For the life of me, I cannot get this to work.
One assembly that does NOT require any other files
or modules or assemblies to be present. Can it be
done?


Ah, an assembly in a single file - no, I don't think *that's* possible
with the standard tools.

Using .netmodule files *is* creating a single assembly, but it's an
assembly spread out over multiple files.

It should be theoretically possible to merge a bunch of .netmodules
into a single file, but I don't know of any tools to do it...

<sfx: tappety tappety>

Now I do. If you go to

http://www.gotdotnet.com/Community/UserSamples/

and search for illink, you should find what you're after. I haven't
tried it, so can't vouch for it working or anything.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #12
Gary Morris <gw*******@hotpop.com> wrote:
Thanks. I'll check it out. From the post it sounded like you
had actually done this. Sorry about the multiple posts, my
server was acting strange and telling me that it could not
send the post, so I kept trying. Obviously it was lying to
me!


Well, I've done it to the extent of checking that I could indeed create
an assembly from modules created by compilers of different languages.
That's not the same as creating an assembly which is all contained
within one file.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #13
Hi Mike,

How is everything going on your side?

As Jon Skeet mentioned, we can compile source file to .netmodule and then
integrate them to an assembly file. However, it can't be done in VS.NET
IDE. The suggestion that Jeffery provided is how to do that in VS.NET IDE.
That should be much more convenient.

If there is any unclear, please feel free to post here and we are glad to
be of assistance.

Thanks very much.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 16 '05 #14
Well, I'm a little dissappointed because it is a very common thing to need a
few lines of VB to do things that aren't available or no one knows how to do
in c# that are build into VB... like BEEP for example, so it rather stinks
to not have an easy way to include VB snippets in a c# .dll, but it
certainly isn't a huge deal to just leave it as a completely seperately
compiled .dll.

I'm just surprised, given all the hype about multi-language support in .NET.
"Yan-Hong Huang[MSFT]" <yh*****@online.microsoft.com> wrote in message
news:Za**************@cpmsftngxa10.phx.gbl...
Hi Mike,

How is everything going on your side?

As Jon Skeet mentioned, we can compile source file to .netmodule and then
integrate them to an assembly file. However, it can't be done in VS.NET
IDE. The suggestion that Jeffery provided is how to do that in VS.NET IDE.
That should be much more convenient.

If there is any unclear, please feel free to post here and we are glad to
be of assistance.

Thanks very much.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 16 '05 #15
Mike Oliszewski <mi***@faxback.com> wrote:
Well, I'm a little dissappointed because it is a very common thing to need a
few lines of VB to do things that aren't available or no one knows how to do
in c# that are build into VB... like BEEP for example, so it rather stinks
to not have an easy way to include VB snippets in a c# .dll, but it
certainly isn't a huge deal to just leave it as a completely seperately
compiled .dll.
Anything you can do in VB.NET you can do in C#, if you know where to
look in the Microsoft.VisualBasic namespace. For Beep, for example, you
can call Microsoft.VisualBasic.Interaction.Beep().
I'm just surprised, given all the hype about multi-language support in .NET.


I don't think so - multi-language support measn that I can work in C#
with a library written in VB.NET, etc. That in itself is far more
important, IMO, than being able to include snippets of both in the same
assembly.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #16
Hi Mike,

I think Jon has explained to you that C# can do everything VB.net can do.
Also, just as him pointed out, we usually do the multi-language work
through library way, and it is for code re-use.

Does this make sense to you? Do you still have concern on this issue?

Please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3055
by: Colin McGuire | last post by:
Hi, I have an report in Microsoft Access and it displays everything in the table. One column called "DECISION" in the table has either 1,2, or 3 in it. On my report it displays 1, 2, or 3. I want...
8
2731
by: sara | last post by:
I am learning Access and programming. I wanted to have the user select the departments for an ad from the list of all departments. Found code (that I could understand) on this site, and it works....
9
3934
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it...
0
3460
by: Jim dunn | last post by:
HI I am having problems with C# with regards to its compatibility with win32 API methods, I am trying to read from a windows CE comm port using C# and imported methods from coredll.dll, it seems...
5
3143
by: Marcel Gelijk | last post by:
Hi, I am trying to create a User Control that is located in a seperate class library. The User Control contains a textbox and a button. The page generates an exception when it tries to access...
3
1490
by: msnews.microsoft.com | last post by:
Hello All, I am trying to write Web Controls and in most of the samples I came across, I am seeing the following function where a HTML string is written to create HTML Controls. ///...
15
4713
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
4
6888
by: Dave Calkins | last post by:
I have a native Win32 C++ app built with Visual Studio 2005. I'd like to make use of a property grid control in this app. For an example of this, in Visual Studio, see the properties control...
53
4595
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
6
1868
by: tshad | last post by:
I was looking at a page that showed how to set up a custom event and it seems to work ok. But I am not sure how I would use it. How would I subscribe to it. There is actual action (such as...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7357
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7012
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5598
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
402
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.