borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Next Topic (Encoding and decoding with Magnetic Card Writer / Reader) New Topic New Poll Post Reply
AndreaVB Forum : VB.Net : MDI application
Poster Message
jorgen
Level: Trainee

Registered: 21-07-2008
Posts: 1

icon MDI application

I am having trouble with a program updated from VB6 to VB.Net, and that is:

When calling a Public sub from ToolStrip, like:

Private Sub NewToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripButton.Click
        Select Case m_iWhichForm
            Case 35 'recipe
                frmRecipe.NewRecord()
            Case Else
        End Select
    End Sub

this sub should now call the Public Sub in the form frmRecipe - but does not.

Please somebody explain what I do wrong in this case.
  

21-07-2008 at 11:42 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
stickleprojects
Level: Moderator


Registered: 09-09-2002
Posts: 1040
icon Re: MDI application

Hi.
In .NET, they finally stopped loading forms for you automatically (yay), so each frm is now a class.
there is no such thing as "frmRecipe", you would need to create an instance of the form ("forms as objects" in MSDN/google)
m_iWhichForm is a variable, right?
When do you change this? How is it kept uptodate? In VB6, on an MDI form, there is no built-in event for which form is active. Do you have a mechanism for detecting the active form? IF so, what does it work on? Most of the code will still work in .NET.

In the simplest case, change your code:

Private Sub NewToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripButton.Click
        Select Case m_iWhichForm
            Case 35 'recipe
                ActiveForm.NewRecord()
            Case Else
        End Select
    End Sub



I think that will work in vb.net.
I note that you haven't supplied the error message (if any).

I suggest you read up on forms as classes  as this is a really really big point of .net.


____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)

23-07-2008 at 07:35 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB.Net : MDI application
Next Topic (Encoding and decoding with Magnetic Card Writer / Reader) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Il portale per lui e lei | Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincaniborder