这个问题与VB2008 Express有关。
我正在制作一个使用结构化属性的用户控件。控件和整个项目都具有相同的结构。问题在于,在主项目中,尝试为此属性分配位置会导致:“对非共享成员的引用需要对象引用。”
我不知道这意味着什么,也不知道如何处理它。Microsoft 的帮助会喋喋不休地说:“您正在引用一个非共享成员,因此需要一个对象引用。”
好吧,微软,我阅读了错误描述,所以没有 shiznit ......但那是什么意思?(我来自 VB6,我是从那里通过示例自学的,所以请放轻松。)
当然,我可以将结构的每个单独部分分配为它自己的属性,例如“街道”“城市”等,但我更喜欢一步完成,因为它由用户控件一次性验证分配时。
有什么帮助让我的用户控件和我的主要项目相互传递一个“地方”吗?
Public Structure Place
Public PlaceName As String
Public Street As String
Public Apt As String
Public City As String
Public State As String
Public Zip As String
Public VerifiedStatus As Integer
Public Lat As Single
Public Lng As Single
End Structure
Public Property CurrentPlace() As Place
Get
Dim ThisPlace As New Place
ThisPlace.Street = Trim(Me.txtStreet.Text)
ThisPlace.Apt = Trim(txtAptNo.Text)
ThisPlace.City = Trim(txtCity.Text)
ThisPlace.State = Trim(lblState.Text)
ThisPlace.Zip = Trim(txtZip.Text)
ThisPlace.Lat = MyLat
ThisPlace.Lng = MyLng
ThisPlace.PlaceName = ""
'This control doesn't take placenames but they exist in the structure.
ThisPlace.VerifiedStatus = MyVerifiedStatus
Return ThisPlace
End Get
Set(ByVal value As Place)
AsLoadedApt = Trim(value.Apt)
AsLoadedCity = Trim(value.City)
AsLoadedLat = value.Lat
AsLoadedLng = value.Lng
AsLoadedState = Trim(value.State)
AsLoadedStreet = Trim(value.Street)
AsLoadedVerifiedStatus = value.VerifiedStatus
AsLoadedZip = Trim(value.Zip)
txtStreet.Text = AsLoadedStreet
txtAptNo.Text = AsLoadedApt
txtCity.Text = AsLoadedCity
lblState.Text = AsLoadedState
txtZip.Text = AsLoadedState
MyVerifiedStatus = AsLoadedVerifiedStatus
MyLat = AsLoadedLat
MyLng = AsLoadedLng
Call ShowStatus()
End Set
End Property