Click here to Skip to main content
15,911,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In one of the forms, after the type of problem has been selected, the c# code for that problem has to be taken from the computer memory. Its something similar to using html links. But i do not know how to go about in this case. My forms are in visual basic and code is in visual c#. Firstly, is it possible to use visual basic and visual c# together? If yes then how can i call or link the code to my form on a click of a button? After finishing with the code it should go to the results form.

What I have tried:

Public Class REDIRECT_TO_CODE_1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

WELCOME.Hide()
PROBLEMS.Hide()
EXISTING_STATIONS.Hide()
Me.Hide()
RESULT.Show()

End Sub
End Class
Posted
Updated 21-Mar-16 23:58pm
Comments
BillWoodruff 22-Mar-16 8:36am    
First, why are you using both VB and C# together ? That is not a wise choice, particularly if you are just starting to program in .NET.

Please clarify: "the c# code for that problem has to be taken from the computer memory" ... are you talking about retrieving the text of code, or actually getting code you can execute at run-time ?

1 solution

You can use VB and C# together, but they need to be separate projects in VS.
Create your code in C#, build it and reference it in your VB part.

Then you can use:
VB
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

 Dim cSharpModule as <your module>
 
 cSharpModule.HandleClickFromVB()
 cSharpModule.Dispose()
End Sub
</your>


But you provided not very much details..
 
Share this answer
 
v2
Comments
BillWoodruff 22-Mar-16 8:58am    
I think you are on track to a +5 answer here, but more detail on what exactly the "C# module" is would be very valuable.
FARONO 22-Mar-16 9:02am    
The "module" would be the C# project that needs to be included in the solution @ Visual Studio. What it should do exactly is not clear with the current details. I forgot to mention the "Imports <your c#="" module="">" at the top of page but that will be shown in the error list.

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