Is there a universal way to get a nice textual representation of a variable in VBA? -


In VBA, is there a good way to represent the text of a variable / object? Like different string of Java.valuef (...) methods.

There is nothing beyond the CSRR, whose limitations you have seen are only one thing you can do Well, write it yourself. Fortunately, VBA has made enough of enough operators to make it easier ('ISARRA, Iseremic', 'Vertip' etc.). (And it surprises you, "Why not just make 'CSRR' more powerful? '' ...)

The work given below is an example. They are for Excel / VBA code, Therefore, you probably do not care about the implementation of the routine of their name, which is for format arrays, etc., but they should give you the original idea.

  'string public function fmt ( Argus) as the diagnosis of the edition itself IsObject (arg) then fmt = fmtObj_ (arg) otherwiseif IsArray (Arg) then fmt = fmtArr_ (arg) 'Note that this test should come after IsArray () Since IsMissing () Returns' empty array The parameter is correct (Array () is made by calling) Alesif ismissing (RGR) then FMT = "& lt; Missing either; select either case varType (arg) case vbDouble 'Since we are in Excel, it does not include two types of characters (#) fmt = CStr (arg) case vbString fmt = "" "& amp; RAG & amp; "" "" Episode vbEmpty fmt = "& lt; blank & gt;" Case vbBoolean, vbDate fmt = CStr (Arg) Episode vbError fmt = fmtExcelVBAError_ (Arg) Episode vbLong fmt = CSRR (RGR) & amp; "& Amp;" Case vbInteger fmt = CSRT (RGR) & amp; "%" Episode vbCurrency fmt = CSRR (RGR) & amp; "@" Episode vbNull fmt = "& lt; null & gt;" The case fmt = "& gt; Typename -" & amp; TypeName (RGR) & amp; "& Gt;" Select end if the lane (FMT) & gt; MAX_FMT_LEN_ then fmt = left (FMT, MAX_FMT_LEN_) & amp; "& Lt; ... & gt;" If the end is in the form of termination function (FMT), but string, "normal" conversion for numbers, and STR (AGR) as an empty public function, if Iobags (RGR) then SORT = FMT ( RGB) otherwise if the veritipp (REGE) = VBS string  
or the varotype (RGE) = vbEmpty or isNumeric (RGR) then totrtr = cstr (arg) else totrtr = Fmt (arg) end ends if

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -