Reputation: 936
What i am trying to do is just make an VB structure, and then assign things to the elements in the structure.
Structure Computer
Public strModel As String
Public dblCost As Double
End Structure
Public Class Form1
Dim homeUse As Computer
homeUse.strModel = "IB-50"
homeUse.dblCost = 2400
End Class
from what i can tell in this code it is correct, but according to visual studios.
homeUse.strModel = "IB-50"
homeUse.dblCost = 2400
are incorrect because of the error "Declaration expected"
Upvotes: 1
Views: 435
Reputation: 32212
You can't set the fields of the structure inline in the class declaration like that. It would need to be inside a method, for instance the constructor:
Public Class Form1
Dim homeUse As Computer
Sub New()
homeUse.strModel = "IB-50"
homeUse.dblCost = 2400
End Sub
End Class
Upvotes: 3