Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hello everyone;
i am new bee in software development..

i have a class in VB.net names as abc.vb
can i use this class in c#.net desktop application project ..??
if yes .. how ..??
if not ...why ..???
Posted

Yes you can. If you compile your VB class to an assembly (DLL).

You can then add the VB assembly as a reference to you C# project.

What it is difficult to do is to mix up VB and C# in the same project.
 
Share this answer
 
Yes, you can use it. If you compile the VB project to a class library (dll) you can reference that library in your C# project. In order to access the types and their members from the C# project, they must be defined as public.


One tutorial: http://www.vbdotnetheaven.com/uploadfile/mahesh/buildingclasslibrary04262005091233am/buildingclasslibrary.aspx[^]
 
Share this answer
 
Comments
Wendelius 19-May-12 5:50am    
Did you read the tutorial in the link. It explains step by step how you make a class library. Another one: http://www.shotdev.com/aspnet/vbnet-component/vbnet-create-class-library-dll/[^]
_Dhull 19-May-12 5:52am    
yaa .. thanks.. got it ..

thanks a lot sir :-)
Wendelius 19-May-12 5:54am    
You're welcome :)
Espen Harlinn 19-May-12 12:21pm    
5'ed!
Congratulations on breaking the 100K barrier :-D
Wendelius 19-May-12 15:54pm    
Thanks, I can feel the weight on my shoulders and the wrinkles around the eyes :)
Put your vb file in vb folder and .cs in cs folder in root

In web.config
Under system.web
<compilation>
<codeSubDirectories>
<add directoryName="vb"/>
<add directoryName="cs"/>
Now close all tags
 
Share this answer
 
ASP.NET
<asp:GridView ID="GridView1"="Gv1" AutoGenerateColumns="true" runat="server" DataKeyNames="nurse_id"
                                                                                        AutoGenerateColumns="true">
                                                                                        <Columns>
                                                                                            <asp:TemplateField HeaderText="Name" SortExpression="name">
                                                                                                <ItemTemplate>
                                                                                                    <asp:HiddenField ID="induid" runat="server" Value='<%# Eval("nurse_id")%>' />
                                                                                                    <asp:Label runat="server" ID="lblname" Text='<%# Eval("name") %>' /></ItemTemplate>
                                                                                                <EditItemTemplate>
                                                                                                    <asp:TextBox ID="txtrewardstype" MaxLength="50" runat="server" Width="100" onkeypress="return isSingleQuoat(event)"></asp:TextBox>
                                                                                                </EditItemTemplate>
                                                                                                <ItemStyle HorizontalAlign="Left" />
                                                                                                <HeaderStyle ForeColor="maroon" Font-Underline="true" HorizontalAlign="left" />
                                                                                            </asp:TemplateField>
                                                                                            
                                                                                            <asp:TemplateField HeaderText="Address" SortExpression="address">
                                                                                                <ItemTemplate>
                                                                                                    <asp:Label runat="server" ID="lbladdress" Text='<%# DataBinder.Eval(Container.DataItem,"address") %>' />
                                                                                                </ItemTemplate>
                                                                                                <ItemStyle HorizontalAlign="Left" />
                                                                                                <HeaderStyle ForeColor="maroon" Font-Underline="true" HorizontalAlign="left" />
                                                                                            </asp:TemplateField>
                                                                                            
                                                                                            <asp:TemplateField HeaderText="Email" SortExpression="email">
                                                                                                <ItemTemplate>
                                                                                                    <asp:Label runat="server" ID="lblemail" Text='<%# DataBinder.Eval(Container.DataItem,"email") %>' />
                                                                                                </ItemTemplate>
                                                                                                <ItemStyle HorizontalAlign="Left" />
                                                                                                <HeaderStyle ForeColor="maroon" Font-Underline="true" HorizontalAlign="left" />
                                                                                            </asp:TemplateField>
                                                                                            <asp:TemplateField HeaderText="Phone" SortExpression="phone">
                                                                                                <ItemTemplate>
                                                                                                    <asp:Label runat="server" ID="lblmobile" Text='<%# DataBinder.Eval(Container.DataItem,"phone") %>' />
                                                                                                </ItemTemplate>
                                                                                                <ItemStyle HorizontalAlign="Left" />
                                                                                                <HeaderStyle ForeColor="maroon" Font-Underline="true" HorizontalAlign="left" />
                                                                                            </asp:TemplateField>
                                                                                            <asp:TemplateField HeaderText="Active" SortExpression="Active">
                                                                                                <ItemTemplate>
                                                                                                    <%# (Boolean.Parse(Eval("Active").ToString())) ? "Yes" : "No" %>
                                                                                                </ItemTemplate>
                                                                                            </asp:TemplateField>
                                                                                            <asp:TemplateField HeaderText="Edit" Visible="false">
                                                                                                <ItemTemplate>
                                                                                                    <asp:ImageButton ID="btn_edit" ToolTip="Edit" runat="server" ImageUrl="~/images/edit-over.gif"
                                                                                                        OnClick="btn_edit_Click" />
                                                                                                </ItemTemplate>
                                                                                                <ItemStyle HorizontalAlign="Center" />
                                                                                                <HeaderStyle HorizontalAlign="Center" ForeColor="Black" />
                                                                                            </asp:TemplateField>
                                                                                            <%--<asp:CommandField ShowEditButton="True" HeaderText="Edit" ButtonType="Image" EditImageUrl="~/images/edit-over.gif"
                                                                    ItemStyle-Width="10px" />--%>
                                                                                            <asp:TemplateField HeaderText="Delete">
                                                                                                <ItemTemplate>
                                                                                                    <asp:ImageButton ToolTip="Delete" ID="btn_remove" OnClick="btn_remove_Click" runat="server"
                                                                                                        ImageUrl="~/images/remove.gif" OnClientClick="document.getElementById('ctl00_ContentPlaceHolder1_hidden111').value='1111';return confirm('Are you sure to delete this Nusre?Do you want to continue?');" />
                                                                                                </ItemTemplate>
                                                                                                <ItemStyle HorizontalAlign="Center" />
                                                                                                <HeaderStyle HorizontalAlign="Center" ForeColor="black" />
                                                                                            </asp:TemplateField>
                                                                                        </Columns>
                                                                                        <HeaderStyle ForeColor="Brown" />                                                                
                                                                                                                                                                  </asp:GridView>
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900