Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
TBD TBD is offline
external usenet poster
 
Posts: 41
Default Does VBA support flattening/serializing to "binary" string?

[Excel 2002 says] Jello again!
(please be patient, there is a question below...)
I'm working on a spreadsheet that's formatted to look like a calendar.
There's a month-name across the top of the sheet (spanning multiple cells);
Weekday names under that, and "days" arranged just like squares you see on a
calendar. Days are always a fixed width (two cells) but each day can hold a
different "list" - the number of rows in each day WILL vary (OK, the days are
really rectangles). It's expected the list in each day will contain 4 to 10
rows.

When the user changes the sheet, it initiaites a lot of input
validation and processing which are very dependent on the date, and row/col
within the date being edited. It seems impractably messy to figure out the
date/row/col from absolute coordinates given that, calendar top/left is
variable, rows/cols between cells is variable, day height (row-count) is
variable, (as user adds rows, can grow, pushing down remaining weeks.) I'm
not saying it's impossible, just impractical.

If not, I could write date/row/col data on a "shadow" sheet. It would
be great if a date/row/col typedef could be cast to/from a string stored in
shadow-sheet:
Q. Is there a way, with VBA, to cast arbitrary data-structures to/from
strings?
Correlary question: Can cells reliably store "binary" strings?

Any help, ideas, constructive criticism is appreciated,
Cheers!


  #2   Report Post  
Posted to microsoft.public.excel.programming
TBD TBD is offline
external usenet poster
 
Posts: 41
Default Awesome, Offace!

Hi Offace,
This is great, definately food for thought - started experimenting and
anticipate it may take a while. Wanted to say THANKS! Assuming VBA doesn't
have a simple casting syntax, you're suggestions seem the best - perhaps only
- alternative.
For the record, this is what I'm trying to accomplish (without CType.)
There would be a symmetric Write function as well.

Thanks/Cheers!
P.S. This reply dialog "differs" from what I'm used to(?)
Code:
Public Type DayKey
  dDate As Date
  iRow As Integer
  iCol As Integer
End Type

Public Sub QD_Read(ByVal AbsRow As Integer, _
                   ByVal AbsCol As Integer, _
                   ByRef dDate As Date, _
                   ByRef datRow As Integer, _
                   ByRef datCol As Integer)
  Dim tKey As DayKey
  
  tKey = CType(WS.Cells(AbsRow, AbsCol).Text, DayKey)
  
  dDate = tKey.dDate
  datRow = tKey.iRow
  datCol = tKey.iCol
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Does VBA support flattening/serializing to "binary" string?



"tbd" wrote in message
...
| [Excel 2002 says] Jello again!
| (please be patient, there is a question below...)
| I'm working on a spreadsheet that's formatted to look like a calendar.
| There's a month-name across the top of the sheet (spanning multiple cells);
| Weekday names under that, and "days" arranged just like squares you see on a
| calendar. Days are always a fixed width (two cells) but each day can hold a
| different "list" - the number of rows in each day WILL vary (OK, the days are
| really rectangles). It's expected the list in each day will contain 4 to 10
| rows.
|
| When the user changes the sheet, it initiaites a lot of input
| validation and processing which are very dependent on the date, and row/col
| within the date being edited. It seems impractably messy to figure out the
| date/row/col from absolute coordinates given that, calendar top/left is
| variable, rows/cols between cells is variable, day height (row-count) is
| variable, (as user adds rows, can grow, pushing down remaining weeks.) I'm
| not saying it's impossible, just impractical.
|
| If not, I could write date/row/col data on a "shadow" sheet. It would
| be great if a date/row/col typedef could be cast to/from a string stored in
| shadow-sheet:
| Q. Is there a way, with VBA, to cast arbitrary data-structures to/from
| strings?
| Correlary question: Can cells reliably store "binary" strings?
|
| Any help, ideas, constructive criticism is appreciated,
| Cheers!

Hello tbd, I am not sure if this is relevant, nor if you have already looked into
these functions.
If they apply then bonus, if not sorry. These functions deal with either
Variants, Objects or Strings as Pointers.

I'm going off a long memory here, you may need to reference stdole library in
references, have you looked at?

- StrPtr(Ptr As String)
- VarPtr(Ptr As Any)
- ObjPtr(Ptr As UnKnown)

All return a Long, being a pointer to in your case a string buffer, that can be
assigned into a Byte() Array. Again this is off a long memory, but you may need
to utilise the RtlMoveMemory API function to copy, and clear the memory allocated.

Now that's in VBA, not an Excel Cell.

By "data-structures" do you mean something like,

Public Type DataStructure

struct member a plenty
End Type

For this take a look at http://vb.mvps.org/tips/varptr.asp, especially the part on
VarPtr, it deals with User-Defined Types.

I really hope there's something in this that will be of use to you, if not my
apologies.

Regard,

- Offace





Reply
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
=SUBSTITUTE(C4,"~?#","") will this work to remove multiple string Raja Mahendiran S Excel Worksheet Functions 6 May 12th 10 09:10 PM
Userform problem with "obj doesn't support this property or method"error message. Chet Excel Programming 0 August 12th 09 05:26 PM
combining or "flattening" rows HWhite Excel Worksheet Functions 6 July 3rd 09 06:40 PM
Converting "uppercase" string data to "lower case" in CSV file [email protected] Excel Discussion (Misc queries) 2 August 12th 08 08:36 PM
text string: "91E10" in csv file auto converts to: "9.10E+11" [email protected] Excel Discussion (Misc queries) 2 August 12th 08 03:13 PM


All times are GMT +1. The time now is 10:49 PM.

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

About Us

"It's about Microsoft Excel"