?
Solved

msstdfmt.dll and vbscripts on windows server 2012

Posted on 2013-12-17
3
Medium Priority
?
746 Views
Last Modified: 2014-10-29
Hi
I have been using a format function based on msstdfmt.dll for many years to help format dates within a VBScript both on clients and servers. (see below).
It appears that msstdfmt.dll is no longer installed as standard on 64 bit operating systems.
Searching the web the advice seems to be to download a copy and register it on the machine running the VBScript.
Is this a sensible thing to do, or will it cause problems?
More importantly, is there a different way of achieving this code. It doesn't seem right to issue VBScript that can't run on a native operating system without downloading old components.

Hope you can help
Andy

Function Format(vExpression, sFormat)
 
     set fmt = CreateObject("MSSTDFMT.StdDataFormat")
     fmt.Format = sFormat

     Set rs = CreateObject("ADODB.Recordset")
     rs.Fields.Append "fldExpression", 12

     rs.Open
     rs.AddNew

     Set rs("fldExpression").DataFormat = fmt
     rs("fldExpression").Value = vExpression

     Format = rs("fldExpression").Value

     rs.close: Set rs = Nothing: Set fmt = Nothing

 End Function
0
Comment
Question by:ieg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Accepted Solution

by:
ieg earned 0 total points
ID: 39726098
Hi
Well with a bit of help from a friend I have re-written this function to use the .Net Framework and not MSSTDFMT.
For those of you interested the code is below.
Andy

'''''''''''''''''''''''''''''''''''''''
'Filename : fn_Format.vbs
'Author   : Andy Latham/Peter Willingham
'Date     : 17/12/2012
'
'This Function simulates the VBA Format Function
'I used to use
'Set fmt = CreateObject("MSSTDFMT.StdDataFormat")  
'but MSSTDFMT is not installed as standard in windows 7 or later
'This technique uses the .Net framework to format strings
'
'It can be used like this
'MsgBox Format("5/6/2007","yyyy-MM-dd")
'MsgBox Format(123456, "#,##0.00")
'MsgBox Format(now(), "dd/MM/yyyy hh:mm:ss")
'
'Please note that some of the custom formatting strings are different between
'MSSTDFMT and the .Net framework (e.g. dd/mm/yyyy is now dd/MM/yyyy)
'
'For Custom Date and Time format strings
'See http://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx
'
'For Custom numeric format strings
'See http://msdn.microsoft.com/en-us/library/0c899ak8(v=vs.110).aspx
'''

Function Format(vExpression, sFormat)

Dim sb
Set sb = createobject("System.Text.StringBuilder")

If isDate(vExpression) Then
    Call sb.AppendFormat ("{0:" & sFormat & "}", cdate(vExpression))
    Format = sb.ToString()
Else
    Call sb.AppendFormat ("{0:" & sFormat & "}", vExpression)
    Format = sb.ToString()
End If


End Function
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question