COM .NET interop

COM .NET interop.

‘ CollTest.vbs
set coll = CreateObject(“System.Collections.Queue”)
coll.Enqueue “Bob”
coll.Enqueue “Joe”
WScript.Echo coll.Dequeue()
WScript.Echo coll.Dequeue()

  • Queue
  • Stack
  • ArrayList
  • SortedList
  • Hashtable
  • System.IO.TextWriter.Write(string, params object[]) // Invoke as Write_17
  • System.IO.TextWriter.Write(string, object, obejct, object) // Invoke as Write_16
  • System.IO.TextWriter.Write(string, object,object) // Invoke as Write_15
  • System.IO.TextWriter.Write(string, object) // Invoke as Write_14
  • System.IO.TextWriter.Write(object) // Invoke as Write_13
  • System.IO.TextWriter.Write(string) // Invoke as Write_12
  • System.IO.TextWriter.Write(decimal) // Invoke as Write_11
  • System.IO.TextWriter.Write(double) // Invoke as Write_10
  • System.IO.TextWriter.Write(float) // Invoke as Write_9
  • System.IO.TextWriter.Write(ulong) // Invoke as Write_8
  • System.IO.TextWriter.Write(long) // Invoke as Write_7
  • System.IO.TextWriter.Write(uint) // Invoke as Write_6
  • System.IO.TextWriter.Write(int) // Invoke as Write_5
  • System.IO.TextWriter.Write(bool) // Invoke as Write_4
  • System.IO.TextWriter.Write(char[], int, int) // Invoke as Write_3
  • System.IO.TextWriter.Write(char[]) // Invoke as Write_2
  • System.IO.TextWriter.Write(char) // Invoke as Write

 

s = “Bob“
Set wrt = CreateObject(“System.IO.StringWriter”)
wrt.Write_12 s

To test the performance of a StringWriter as compared to concatenating a VB string I ran the following script:

‘stringtest.vbs
WScript.Echo Now
s = “”
for i = 1 to 100000
s = s & CStr(i)
next
WScript.Echo Now

set wrt = CreateObject(“System.IO.StringWriter”)
for i = 1 to 100000
s = CStr(i)
wrt.Write_12 s
next
s = wrt.GetStringBuilder().ToString()
WScript.Echo Now

 

AppendFormat ( System.IFormatProvider provider , System.String format , params object[] args )
AppendFormat ( System.String
format , params object[] args )
AppendFormat ( System.String
format , System.Object arg0 , System.Object arg1 , System.Object arg2 )
AppendFormat ( System.String format , System.Object arg0 , System.Object arg1 )
AppendFormat ( System.String
format , System.Object arg0 )

Let’s see if we could easily use one of them:

‘sbtest.vbs
set sb = CreateObject(“System.Text.StringBuilder”)
sb.AppendFormat_5 Nothing, “{0} is a {1} number” & vbCrLf, Array(1, “loneliest”)
sb.AppendFormat_5 Nothing, “{0} is a {1} number” & vbCrLf, Array(2, “happiest”)
WScript.Echo sb.ToString()

 

 

 

 

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s