Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
=SUBSTITUTE(C4,"~?#","") will this work to remove multiple string | Excel Worksheet Functions | |||
Userform problem with "obj doesn't support this property or method"error message. | Excel Programming | |||
combining or "flattening" rows | Excel Worksheet Functions | |||
Converting "uppercase" string data to "lower case" in CSV file | Excel Discussion (Misc queries) | |||
text string: "91E10" in csv file auto converts to: "9.10E+11" | Excel Discussion (Misc queries) |