0

I am writing a VB.net application and have included a c# dll. The c# dll has a class called WelcomeScreen. This class has a form (I saw this in the Object Browser). How can I show this form in my VB.net application?

This is the code I have so far:

Public Class Form1
Dim welcome As New WelcomeScreen(1)
welcome.Show()
user3229570
  • 853
  • 2
  • 10
  • 23
  • Have you tried anything and are getting an error? It is no different from accessing VB classes. – Praveen Paulose Apr 12 '15 at 17:55
  • The only thing I have done is put in the line "Dim c As New WelcomeScreen(1)". But I don't know what to do to show the form. Any advice would be greatly appreciated. – user3229570 Apr 12 '15 at 18:00
  • Have you tried c.Show()? – Praveen Paulose Apr 12 '15 at 18:01
  • 1
    Duplicate of [Using a class in a VB.net project](http://stackoverflow.com/questions/29583282/using-a-class-in-a-vb-net-project). Why are you reposting this? If you didn't get a satisfactory answer then edit your original question. – The Blue Dog Apr 12 '15 at 18:04
  • I just tried that and tried to build. I got "Declaration expected" for line 7. There was also a big warning message "There was a mismatch between the processor architecture of the project being built 'MSIL' and the processor architecture of the reference 'TIProGUI', 'x86' – user3229570 Apr 12 '15 at 18:08
  • Please paste the code in and around line 7 – Praveen Paulose Apr 12 '15 at 18:09

1 Answers1

0

It is no different from showing a form in VB.

Dim welcomeScreen as New WelcomeScreen()
welcomeScreen.Show()

For basic information of forms in VB.NET you can read this post http://www.dummies.com/how-to/content/opening-closing-and-hiding-forms-with-visual-basic.html

It is a nice starting point for basics in VB forms.

Praveen Paulose
  • 5,741
  • 1
  • 15
  • 19
  • Thanks. I tried that and got the error message above. – user3229570 Apr 12 '15 at 18:10
  • I assume you are writing show with a capital "S" and ending it with brackets as in "welcome.Show()" – Praveen Paulose Apr 12 '15 at 18:16
  • Thanks. I just changed it to " welcome.Show()" and still get the same error. Grrr. – user3229570 Apr 12 '15 at 18:18
  • For the warning that you receive, refer to this answer and let me know if it helps http://stackoverflow.com/questions/10113532/how-do-i-fix-the-visual-studio-compile-error-mismatch-between-processor-archit Though it is for a C++ and a C# project, the same steps should help you. – Praveen Paulose Apr 12 '15 at 18:21
  • Thanks. I followed the steps and the warning went away. But I still have the error saying "Declaration expected". What does this mean? – user3229570 Apr 12 '15 at 18:23
  • Why are you passing a 1 in your constructor? – Praveen Paulose Apr 12 '15 at 18:25
  • @user3229570 You need to put the `.Show` code in a sub or function somewhere, and not in class declaration part. E.g. `Public Class Form1 : Public Sub New() : Me.InitializeComponent() : Dim welcomeScreen as New WelcomeScreen() : welcomscreen.Show() : End Sub : End Class` – Jens Apr 12 '15 at 18:44
  • Thanks! I did this and it compiles just fine. The problem is I don't know how to call the sub-routine inside Module1. I tried Module1.Show_it() but it gave me the same error "Declaration expected". – user3229570 Apr 12 '15 at 19:38
  • I added a button to the form that calls Show_it() in the module and it works great. Thank you. – user3229570 Apr 12 '15 at 20:21