Thursday, August 6, 2009

Interfacing With .NET in VBScript

It turns out that interfacing with the .NET API in VBScript is a simple as this:

   1: Set q = CreateObject("System.Collections.Queue")
   2: q.Enqueue "Foo"
   3: q.Enqueue "Bar"
   4: q.Enqueue "Baz"
   5:  
   6: While q.Count > 0
   7:     WScript.Echo q.Dequeue()
   8: Wend
   9:  
  10: Set rng = CreateObject("System.Random")
  11:  
  12: For i = 0 To 10
  13:     WScript.Echo rng.Next()
  14: Next

Who knew?

0 comments:

Post a Comment