2 projects in one solution? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

2 projects in one solution?

mlmill4mlmill4 Posts: 2Member
I have an issue with a VB.NET program I am developing in Visual Studio. It has 2 projects in its solution - one project is for command buttons and the other is for SQL Query forms.

I need a command button in the first project, called QueryCommand.vb, to be able to open a form located in the second project called QueryForm.vb. I know that if you're working in a single project, then QueryForm.show() is used to open the form, but what about calling it from a different project?

Currently, using QueryForm.show() from the command buttons project complains that QueryForm is not declared. Is there a way to declare the form globally for all projects in a solution?

Thanks,
ML

Comments

  • seancampbellseancampbell Pennsylvania, USAPosts: 684Member ✭✭✭
    Well, I am not on my work PC so I don't have VS available to test if this answer is right (I will check first thing tomorrow morning) but I think I know how to do what you want.

    In Vb 6.0, I beleive you could do frmQuery.Show() and have it show a form, but in VB.Net it is a bit different. You need to declare a variable as the form object then do a show so this is what it would look like:

    [Code]
    Dim F as frmQuery
    F = new frmQuery()
    F.Show()
    [/code]
    Alternatively
    [Code]
    Dim F as new frmQuery()
    F.Show()
    [/code]

    Now when you reference objects like frmQuery, Integer, String, etc there is an assumed namespace. So if you want one project to interact with another I beleive you can access the components by drilling into thier namespaces (excuse the vocab on this, I think I might be calling these wrong)

    So if I have a project called SeanIsCool and another called NoHesNot and I wanted to show a form from NoHesNot in the SeanIsCool project my code would look similar to this:

    [Code]
    'I warn you this is not tested and could be a bad answer
    'If that is the case I will be deleting this post tomorrow
    '--
    'This code goes under an event inside of project SeanIsCool
    'That meens it could be on a button click, mousedown, etc on any
    'form or Sub Main()
    '--
    Dim F as new NoHesNot.frmQuery()
    F.Show()
    [/code]

    I will verify if this is correct or not and edit this post tomorrow, but if you see this tonight, try some variations of that and see if you cannot find a solution. Post it if you do!

    Happy Coding
    Firesickle.com
  • mlmill4mlmill4 Posts: 2Member
    Thanks, I tried doing this and it seems to work partially - I have an OpenFileDialog which is triggered whenever the form is shown. When I use the code you suggested, the OpenFileDialog appears and prompts for the database file, but the form still does not show.

    It seems to be calling the QueryForm.vb code, but still not showing the actual form. Is there anything else I might be missing?

    Thanks,
    ML


    : Well, I am not on my work PC so I don't have VS available to test if
    : this answer is right (I will check first thing tomorrow morning) but
    : I think I know how to do what you want.
    :
    : In Vb 6.0, I beleive you could do frmQuery.Show() and have it show a
    : form, but in VB.Net it is a bit different. You need to declare a
    : variable as the form object then do a show so this is what it would
    : look like:
    :
    : [Code]
    : Dim F as frmQuery
    : F = new frmQuery()
    : F.Show()
    : [/code]:
    : Alternatively
    : [Code]
    : Dim F as new frmQuery()
    : F.Show()
    : [/code]:
    :
    : Now when you reference objects like frmQuery, Integer, String, etc
    : there is an assumed namespace. So if you want one project to
    : interact with another I beleive you can access the components by
    : drilling into thier namespaces (excuse the vocab on this, I think I
    : might be calling these wrong)
    :
    : So if I have a project called SeanIsCool and another called NoHesNot
    : and I wanted to show a form from NoHesNot in the SeanIsCool project
    : my code would look similar to this:
    :
    : [Code]
    : 'I warn you this is not tested and could be a bad answer
    : 'If that is the case I will be deleting this post tomorrow
    : '--
    : 'This code goes under an event inside of project SeanIsCool
    : 'That meens it could be on a button click, mousedown, etc on any
    : 'form or Sub Main()
    : '--
    : Dim F as new NoHesNot.frmQuery()
    : F.Show()
    : [/code]:
    :
    : I will verify if this is correct or not and edit this post tomorrow,
    : but if you see this tonight, try some variations of that and see if
    : you cannot find a solution. Post it if you do!
    :
    : Happy Coding
    : Firesickle.com

  • seancampbellseancampbell Pennsylvania, USAPosts: 684Member ✭✭✭
    That is strange, how are you attempting to connect to the DB, using a control?

    -sc
Sign In or Register to comment.