LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ken Ken is offline
external usenet poster
 
Posts: 207
Default class module variable declaration issue

Since receiving Peter's response to my post on using a fixed length
string variable in a class module I have gotten a lot smarter on Get/
Let pairs and class modules in general (mostly from Chip Pearson's
site); but unfortunately I'm stll not smart enough.

Below is a trimmed down (only 1 variable instead of 24) version of my
code. I don't get any errors, but, I don't get any immediate window
output either.

In a regular module I have:

Option Explicit

Sub CreatePOHeader()

Dim POHeaders As New Collection
Dim i As Integer
Dim PH As POHeader

Dim PO_ID As String * 10

PO_ID = "LM123145"

Set PH = New POHeader
PH.PO_ID = PO_ID

POHeaders.Add PH, PH.PO_ID

For i = 1 To POHeaders.Count
Debug.Print POHeaders(i).PO_ID
Next i

End Sub

In my POHeader Class module I have:

Option Explicit

Private pPO_ID As String * 10

Public Property Get PO_ID() As String
PO_ID = pPO_ID
End Property

Public Property Let PO_ID(value As String)
pPO_ID = PO_ID
End Property

Once I get to the point where I can my 24 fixed length string
variables in a class I will loop through a range on my spreadsheet to
create a collection, and ultimately use the collection to generate the
data file that is needed for the accounting system preprocessor.

Thanks

Ken


Initial Post:

I am generating a fixed length text file from my Excel 2003 data for
import into an accounting system. I have it working okay by padding
the cells with spaces and trimming appropriately before stringing the
cell values together for export. I was hoping to simplify my process
with a class module with properly lengthed string variables; but, I
don't seem to be able to declare fixed length string variable as
Public. I have a POHeader class module and i want to have e.g.

public PO_ID As String * 10


I can use Dim PO_ID As String * 10 in my regular module and it works;
but if I use that in the POHeader class module I can't get to it from
the regular module. Is this a limitation of class modules or am I
overlooking something or does anyone have any other ideas?


Thanks


Ken

Peter's response:

There are various things that can't be declared as public in class/
object
modules, and a fixed length string is one of them.

A simple workaround is to declare as private and use a [public]
property
let/get pair to access it.

Regards,
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CLASS MODULE & SIMPLE MODULE FARAZ QURESHI Excel Discussion (Misc queries) 1 September 7th 07 09:32 AM
Class Module vs Normal Module Les Excel Programming 2 July 20th 07 09:54 AM
Variable from a sheet module in a class module in XL XP hglamy[_2_] Excel Programming 2 October 14th 03 05:48 PM
Pass a variable from a class module pk Excel Programming 1 October 2nd 03 08:24 PM
Variable Declaration?? Tom Ogilvy Excel Programming 1 August 8th 03 06:45 PM


All times are GMT +1. The time now is 11:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"