VB 2010元素到变量

时间:2013-04-29 20:22:58

标签: visual-studio-2010 variables data-structures

如果您在VB 2010中为HousePet构建了一个结构,并且想要访问名为Coat的结构元素,那么将该元素移动到变量中所需的代码行是什么{ {1}}?

Coat

2 个答案:

答案 0 :(得分:2)

首先,你需要一个Struct类型的变量:

Private MyPet As HousePet

然后你可以像这样访问它:

Coat = MyPet._PetCoat

答案 1 :(得分:2)

'Public _Cost as Double
'A Typo?
'Did you mean Public _Coat as Double

Sub Main()
    Dim HoundDog As HousePet
    Dim Coat As String

    Dim x As HousePet

    Coat = x._Cost 'Or is it a typo? x._Coat?
End Sub