Hi @StewartBW ,
If you declare variables with the same names (Name
and Home
) inside a method or another structure, they are considered different because they are in different scopes.
Public Structure Blah
Public Name As String
Public Home As String
End Structure
Public Structure AnotherBlah
Public Name As String
Public Home As String
End Structure
Public Sub ExampleMethod()
Dim Name As String = "LocalName"
Dim Home As String = "LocalHome"
Dim myBlah As Blah
myBlah.Name = "BlahName"
myBlah.Home = "BlahHome"
Dim myAnotherBlah As AnotherBlah
myAnotherBlah.Name = "AnotherBlahName"
myAnotherBlah.Home = "AnotherBlahHome"
Console.WriteLine(Name) ' Outputs: LocalName
Console.WriteLine(Home) ' Outputs: LocalHome
Console.WriteLine(myBlah.Name) ' Outputs: BlahName
Console.WriteLine(myBlah.Home) ' Outputs: BlahHome
Console.WriteLine(myAnotherBlah.Name) ' Outputs: AnotherBlahName
Console.WriteLine(myAnotherBlah.Home) ' Outputs: AnotherBlahHome
End Sub
Best Regards.
Jiachen Li
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.