Format Function for VBS 
Author Message
 Format Function for VBS

Hello all --

Here's a home grown VBS function that simulates most (if not all) of the
functionality of the VB Format function (sFormat should allow all the same format
definitions).  It is a bit of a kluge, but it seems to work...

(It relies on ADO and the MSSTDFMT.dll (from Visual Studio 6) being installed on
the machine that it is to run on)

Function Format(vExpression, sFormat)
  Const adVariant = 12

  Dim objFMT
  Dim objRS

  If Len(vExpression) > 0 Then
    Set objFMT = CreateObject("MSSTDFMT.StdDataFormat")
    objFMT.Format = sFormat

    Set objRS = CreateObject("ADODB.Recordset")

    objRS.Fields.Append "fldExpression", adVariant


    'Apply format
    Set objRS("fldExpression").DataFormat = objFMT
    objRS("fldExpression").Value = vExpression
    Format = objRS("fldExpression").Value

    Format = ""
  End If

  Set objRS = Nothing
  Set objFMT = Nothing

End Function


Scott Dixon, President
Big Dog Consulting, Inc.
"The software we write doesn't bite!"

Fri, 12 Sep 2003 08:21:49 GMT  
 [ 1 post ] 

 Relevant Pages 

1. ijg format accidently changed to vbs format

2. Problems using format and format$ functions

3. What API Function to format a disk and How to format a disk

4. new vbs with format name ?

5. Formatted output in VBS

6. Format function in VBScript

7. Format function in VBScript?

8. Need Format Function

9. Problem with Format Functions

10. Format() function error in VBScript

11. VBScript Functions Summary (HTML format)

12. using the format function...


Powered by phpBB® Forum Software