vb.net写了一个类,给这个类的属性赋值是总是提示该属性不是类的成员,求解
类代码:ImportsMicrosoft.VisualBasicPublicClasscustinfoPrivatestrCpNameAsStringPublicProp...
类代码:
Imports Microsoft.VisualBasic
Public Class custinfo
Private strCpName As String
Public Property CpName() As String
Get
Return strCpName
End Get
Set(ByVal value As String)
strCpName = value
End Set
End Property
Private strCpFax As String
Public Property CpFax() As String
Get
Return strCpFax
End Get
Set(ByVal value As String)
strCpFax = value
End Set
End Property
Private strLink1 As String
Public Property Link1() As String
Get
Return strLink1
End Get
Set(ByVal value As String)
strLink1 = value
End Set
End Property
End Class
调用页面:
Partial Class test
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim cust As New custinfo()
cust.CpName = "公司"
MsgBox(cust.CpName)
End Sub
End Class
结果是:
编译器错误消息: BC30456: “CpName”不是“custinfo”的成员。
源错误:
行 34: Cust.CpName = cpName.Trim
行 35: Cust.CpTel = cpTel.Trim
行 36: Cust.CpFax = cpfax.Trim 展开
Imports Microsoft.VisualBasic
Public Class custinfo
Private strCpName As String
Public Property CpName() As String
Get
Return strCpName
End Get
Set(ByVal value As String)
strCpName = value
End Set
End Property
Private strCpFax As String
Public Property CpFax() As String
Get
Return strCpFax
End Get
Set(ByVal value As String)
strCpFax = value
End Set
End Property
Private strLink1 As String
Public Property Link1() As String
Get
Return strLink1
End Get
Set(ByVal value As String)
strLink1 = value
End Set
End Property
End Class
调用页面:
Partial Class test
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim cust As New custinfo()
cust.CpName = "公司"
MsgBox(cust.CpName)
End Sub
End Class
结果是:
编译器错误消息: BC30456: “CpName”不是“custinfo”的成员。
源错误:
行 34: Cust.CpName = cpName.Trim
行 35: Cust.CpTel = cpTel.Trim
行 36: Cust.CpFax = cpfax.Trim 展开
展开全部
在vb.net窗口程序里测试你的代码没有问题,所以应该是其他问题.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Protected Sub s_Msg()
Dim cust As New custinfo()
cust.CpName = "公司"
MsgBox(cust.CpName)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
s_Msg()
End Sub
End Class
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Protected Sub s_Msg()
Dim cust As New custinfo()
cust.CpName = "公司"
MsgBox(cust.CpName)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
s_Msg()
End Sub
End Class
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询