If I have a console application containing the class
public class HelloWorld
{
public string Hello()
{
return "hi";
}
}
I can go into the immediate window at design time and do
new HelloWorld().Hello()
But, if I try
? Hello()
I get error “The name ‘Hello’ does not exist in the current context”. So it appears I need to instantiate the class first. That makes sense.
But, my confusion comes from the MSDN documentation where they show
Module Module1
Sub Main()
MyFunction(5)
End Sub
Function MyFunction(ByVal input as Integer) As Integer
Return input * 2
End Function
End Module
They say all you have to do is type
?MyFunction(2) in the Immediate window and press Enter.
I’m not a VB.NET guy. Am I correct in assuming I need to instantiate my object first? Why does the VB.NET example differ?
This is in a Module, not in a class. Modules are leftovers from the days of yore (i.e., VB6).