1

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

Structure HousePet
   Public _Breed as String
   Public _PetCoat as String
   Public _Cost as Double
End Structure

   Sub Main()
        Dim HoundDog As HousePet
        Dim Coat as String
        **Insert Code Here**
   End Sub
4

2 回答 2

2

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

Private MyPet As HousePet

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

Coat = MyPet._PetCoat
于 2013-04-29T20:37:11.123 回答
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
于 2013-04-29T20:37:39.370 回答