RESOLVED: Just made the switch from VB6 to .NET yesterday...
I searched on this topic already and couldn't find anything that directly related to my problem. Sorry if this is a repost.
I just made the switch from VB6 to VB.NET last night and I'm having some trouble. I have searched Google, read newbie tutorials, and I just can't find a solution to a really simple problem. I have never done OOP before so this is almost like learning to write code for the very first time.
My problem is this. I have a linklabel, and inside of it is this code:
Okay, so now I click the link label and the window opens fine. But if I click it again a new instance opens. That is to be expected. So I figured I'd try making it static. That solved the multiple instances problem but if I closed the form and clicked the linklabel again I got an error. Okay, strange that I can't do that but I guess I understand. I tried module level as well, which had the same problem (didn't think that was a viable solution anyway).
I just can't seem to get around this very simple thing. Also, in future projects I may not want to keep the variable in the linkclicked event because I will want to be able to control the form from other parts of the program. If anybody could show me what it is I'm missing I'd appreciate it.
Sorry for such a newbie question.
Edit: Also, I have tried it this way with no difference:
Same problem.
I searched on this topic already and couldn't find anything that directly related to my problem. Sorry if this is a repost.
I just made the switch from VB6 to VB.NET last night and I'm having some trouble. I have searched Google, read newbie tutorials, and I just can't find a solution to a really simple problem. I have never done OOP before so this is almost like learning to write code for the very first time.
My problem is this. I have a linklabel, and inside of it is this code:
VB.NET:
Dim newAbout as New frmAbout
newAbout.Show
Okay, so now I click the link label and the window opens fine. But if I click it again a new instance opens. That is to be expected. So I figured I'd try making it static. That solved the multiple instances problem but if I closed the form and clicked the linklabel again I got an error. Okay, strange that I can't do that but I guess I understand. I tried module level as well, which had the same problem (didn't think that was a viable solution anyway).
I just can't seem to get around this very simple thing. Also, in future projects I may not want to keep the variable in the linkclicked event because I will want to be able to control the form from other parts of the program. If anybody could show me what it is I'm missing I'd appreciate it.
Sorry for such a newbie question.
Edit: Also, I have tried it this way with no difference:
VB.NET:
Module Module1
Dim about As frmAbout
End Module
Private Sub llblAbout_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles llblAbout.LinkClicked
about = New frmAbout
about.Show()
End Sub
Same problem.
Last edited: