-2

I have a problem in upgrading a program from VB6 to .NET which I hope someone can help me with. I am a new .NET programmer so I hope you can be quite specific in your assistance as my knowledge base is very low.

I get 3 errors which are the same "Name 'load' is not declared". Can you help please? Many thanks in anticipation of assistance.

Public Sub Main()

    'Load all forms
    'UPGRADE_ISSUE: Load statement is not supported. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="B530EFF2-3132-48F8-B8BC-D88AF543D321"'
    Load(frmStartup)
    'UPGRADE_ISSUE: Load statement is not supported. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="B530EFF2-3132-48F8-B8BC-D88AF543D321"'
    Load(frmBlankScreen)
    'UPGRADE_ISSUE: Load statement is not supported. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="B530EFF2-3132-48F8-B8BC-D88AF543D321"'
    Load(frmQuestions)
    frmStartup.Show()
End Sub
potame
  • 7,597
  • 4
  • 26
  • 33
  • It means you should look into not [accessing forms by their class name](http://stackoverflow.com/a/6049062/11683) anymore. Create forms with `New` when needed and use [`Using`](https://msdn.microsoft.com/en-us/library/htd05whh.aspx) around that. – GSerg Oct 19 '15 at 07:23
  • Thanks but can you demonstrate as I have no idea how to operationalize your comment ... sorry but my knowledge base is very small – user3103415 Oct 19 '15 at 07:37

1 Answers1

1

Like it says, "Load" isn't supported in VB.Net. You need to create an instance of your form (and, you can create multiple instance of it if needed). Here, we declare an instance of your form, then we show it. This should give you the behavior you're expecting.

' Declare an instance of the form and show it
Dim form As New frmStartup
form.Show()
b.pell
  • 3,873
  • 2
  • 28
  • 39
  • Great thanks. I presume that from this point on I refer to form instead of frmstartup and then close form when finished. – user3103415 Oct 20 '15 at 03:24
  • is it possible to do: dim frmStartup as New frmStartup so that it is not necessary to edit any more code ? – user3103415 Oct 20 '15 at 04:23
  • Yes, you can do that. Visual Studio/the compiler is smart enough to when you're talking about the instance vs. the object. From a best practices/readability stance, it's probably not a great idea but it will work. The other thing you can do is use Visual Studio, right click on the variable and choose "Rename" after you get it working (it should rename the variable in that scope in all the code locations). – b.pell Oct 20 '15 at 15:39
  • Many thanks for coming back to this and helping - I have managed to really progress thanks to your assistance. Cheers to you! – user3103415 Oct 21 '15 at 20:21
  • Glad to help! Best of luck. – b.pell Oct 22 '15 at 14:44