TungVan
asked on
property let/get for string
Hi,
I declared a string like this:
Dim sService as String * 16
How can I make property let/get for this?
**************************
Public Property Get Service() As String * 16
Service= m_sService
End Property
**************************
Public Property Let Service(ByRef pValue As String * 16)
m_sService = pValue
End Property
**************************
Those functions give me errors..
Thanks
I think you just messed your variable up because it isn't the same name you declared it as.
Above you have Dim sService as String * 16
but it should actually be m_Sservice like you have in your Let/Get statements.
Above you have Dim sService as String * 16
but it should actually be m_Sservice like you have in your Let/Get statements.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Option Explicit
Private m_Service As String * 16
Public Property Get Service() As String
Service = m_Service
End Property
Public Property Let Service(ByVal pValue As String)
m_Service = pValue
End Property
'Form 1
Option Explicit
Dim c As Class1
Private Sub Command1_Click()
Set c = New Class1
'String buffer is 16 so the return will only be 16 characters long if you go beyond 16
'If the string is less then 16 then the length remains 16 but with appended CHR(0)
' returns: (123456789.123456)
' ommits: (78)
c.Service = "123456789.12345678" '18 long
MsgBox c.Service
End Sub