Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Convert some VB code to C#

Convert some VB code to C#

Scheduled Pinned Locked Moved C#
csharpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gareth_Hastings
    wrote on last edited by
    #1

    Hello, I'm converting some VBS scripts to C# and one of them uses the following lines of code Set MyDCOM = CreateObject("NODMON.NODCLS") retval = MyDCOM.addmsg("", "", 1, Now, 0, 3000, Message) Could someone point me in the right direction for how I should go about converting this? It's mainly the CreateObject statement I'm unsure of!. Thanks

    N 1 Reply Last reply
    0
    • G Gareth_Hastings

      Hello, I'm converting some VBS scripts to C# and one of them uses the following lines of code Set MyDCOM = CreateObject("NODMON.NODCLS") retval = MyDCOM.addmsg("", "", 1, Now, 0, 3000, Message) Could someone point me in the right direction for how I should go about converting this? It's mainly the CreateObject statement I'm unsure of!. Thanks

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      Gareth_Hastings wrote: Set MyDCOM = CreateObject("NODMON.NODCLS") retval = MyDCOM.addmsg("", "", 1, Now, 0, 3000, Message) What you are doing here is late binding in VB. While C# does support late-bound object creation (i.e.; look at Activator.CreateInstance), there are several ways to access what you are doing. One is to generate the appropriate interop assemblies (for example if you are using Visual Studio .NET you can simply use the Add Reference -> COM tab), this will allow you to declare the object and take advantage of early-binding at compile-time or you could use reflection to generate the object at run-time (the Activator class). - Nick Parker
      My Blog | My Articles

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups