Reference to a non-shared member requires an object reference in VB.net

前端 未结 3 1356
我寻月下人不归
我寻月下人不归 2020-12-21 14:25

I have a VB.net program that I got from someone else. It is comprised of a main form and 6 other modules (all .vb files). These files all have a \"VB\" icon next to them i

3条回答
  •  没有蜡笔的小新
    2020-12-21 14:52

    It means that the routine you are trying to call needs to reference an instance of the form to access the routine. You can either reference an instance as Alex says, or you can make the routine 'Shared', so it doesn't need an instance. To do this, change the definition in QuoteMgr.vb to

    Friend Shared Sub StartGettingQuotesLevel2(ByVal oSymbol As String)
    

    Switching it to `Shared' may start showing compiler errors, if the routine accesses form controls or module-level variables. These will need to be added to the parameter list.

提交回复
热议问题