Re: How to export a UDT from a Class

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



"Tony Proctor" <tony_proctor@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:%23PxI5V5ZFHA.2288@xxxxxxxxxxxxxxxxxxxxxxx
>I have a problem with exporting a UDT from a Public class and have it being
> modifiable. It may be related to something I thought was a bug a couple of
> years ago
> (http://groups.google.ie/group/microsoft.public.vb.bugs/msg/4f99d5da34f04162
> ?hl=en)
>
> Note that isn't the usual problem of not being able to export UDTs unless
> the Type is Public and in a Public class. Everyone knows that one. No, in

Even stranger... lose the With/End With and it doesn't work at all... but
create a class property for each member of the UDT and it works always.
'==========
Option Explicit

Dim o As Class1

Private Sub Command1_Click()
Debug.Print o.Var.s
End Sub

Private Sub Form_Load()
Set o = New Class1
o.Var.s = "Hello"
Debug.Print o.Var.s
End Sub
'==========

Separate property for each member of UDT works....
'===========Form
Option Explicit

Dim o As Class1

Private Sub Command1_Click()
Debug.Print o.VarS
End Sub

Private Sub Form_Load()
Set o = New Class1
o.VarS = "Hello"
Debug.Print o.VarS
End Sub
'===========Class
Option Explicit

Public Type t
s As String
End Type

Private tVar As t

Public Property Get VarS() As String
VarS = tVar.s
End Property

Public Property Let VarS(Arg As String)
tVar.s = Arg
End Property
'===========

What a pain... eh? <g>

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Please keep all discussions in the groups..


.



Relevant Pages

  • Re: How to export a UDT from a Class
    ... Creating a Get/Let for the UDT and using that works ... Dim o As Class1 ... Private Sub Command1_Click ... Private tVar As t ...
    (microsoft.public.vb.bugs)
  • How to export a UDT from a Class
    ... I have a problem with exporting a UDT from a Public class and have it being ... Private Sub Command1_Click ...
    (microsoft.public.vb.bugs)
  • Re: Problem with arraylist
    ... Private Sub Form1_Load(ByVal sender As Object, ... Dim array As New ArrayList ... Dim classs As New Class1 ... Public Class Class1 ...
    (microsoft.public.dotnet.languages.vb)
  • Re: VSTO AddAdvise Problem
    ... I think you need to add the _ before Public Class ... Private applicationEventSink As Visio.IVisEventProc ... Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ... Dim majorVersion As Int16 = 0 ...
    (microsoft.public.visio.developer)
  • RE: Nested Datagrid spanning columns of Parent Datagrid
    ... (basically all the code that you have enclosing the Public Class ... Private Sub Page_Init(ByVal sender As System.Object, ... Protected ChildGrid As MIMSearch.ChildDataGrid ... Dim dt As DataTable ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)