Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8342043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:39:29+00:00 2026-06-09T05:39:29+00:00

In VBScript, you can use certain .net classes using COM automation. This comes in

  • 0

In VBScript, you can use certain .net classes using COM automation. This comes in handy when you want to use dynamic arrays, lists, queues etc.

It would be nice if I could use strings as objects, so I could do all fancy string stuff with it, but whenever I pass a string from another object, it is seen by VBScript as a literal string and not as a string object:

Set s = CreateObject("System.Text.StringBuilder")
s.Append_3 "I love deadlines. I like the whooshing sound they make as they fly by."

' This gives me the literal string
MsgBox s.ToString
text = s.ToString

' But unfortunately this won't work
MsgBox s.ToString.Length
Set stringRef = s.ToString

Also creating a string as a COM object won’t work:

Set s = CreateObject("System.String")      ' Nope.

Is there someone who did manage this, or is having other thoughts about it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:39:30+00:00Added an answer on June 9, 2026 at 5:39 am

    You can use some methods and properties, just not all of them.
    The following works, but from the moment you use toString you have a vbscript variable which behaves as such.

    Set s = CreateObject("System.Text.StringBuilder")
    s.Append_3 "I love deadlines. I like the whooshing sound they make as they fly by."
    s.Append_3 "and the rest."
    wscript.echo s.Length
    wscript.echo s.Capacity
    wscript.echo chr(s.chars(0))
    wscript.echo s.Replace("t", "d").Replace("l", "k").toString
    

    gives

    83
    140
    I
    I kove deadkines. I kike dhe whooshing sound dhey make as dhey fky by.and dhe resd.
    

    But eg the following doesn’t work, although it is a method of stringbuilder http://msdn.microsoft.com/en-us/library/system.text.stringbuilder_methods.aspx
    don’t ask me why

    s.Insert 1, "insert this"
    

    and

    s.Insert_2 7, "insert this"
    

    does work

    I also program in Ruby where you can use these objects also and there it is the same behavior. For some objects i can enumerate the properties or methods like eg for Excel

    require 'win32ole'
    excel = WIN32OLE.new('Excel.Application')
    properties = excel.ole_get_methods
    properties.each do |property|
      p property.to_s
    end
    

    gives a very long list like

    "Application"
    "Creator"
    "Parent"
    "ActiveCell"
    "ActiveChart"
    "ActiveDialog"
    "ActiveMenuBar"
    "ActivePrinter"
    "ActiveSheet"
    "ActiveWindow"
    "ActiveWorkbook"
    etc etc
    

    But not so for System.Text.Stringbuilder, i suppose it is due to the way the programmer exposes his methods and properties to the outside.

    Sadly, i don’t think it is possible to directly use System.String in vbscript.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a regular expression that I can use in VBScript and .NET that
I have a .NET library that I'm trying to use via COM (hMailServer's VBScript
Inside a classic asp page, I'm told that you can use vbscript or jscript.
24x7 from SoftTree Technologies can use both JAL and VBScript for scripting. Does anyone
How can I make my class library STA for use with CreateObject in VBScript?
I want to run a VBScript file from an Ant script. How can I
I want to run vbscript file using cscript.exe. i searched a lot but did'nt
How can I determine whether a file is in use via VBScript or a
How would do you call GetBytes (of System.Text.UTF8Encoding) from VBScript? You can use the
This question is a follow-up to the one at Can I use a language

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.