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. Visual Basic
  4. Left$, Right$, Trim$, "$" Advice.

Left$, Right$, Trim$, "$" Advice.

Scheduled Pinned Locked Moved Visual Basic
questioncsharpdotnetalgorithms
5 Posts 4 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.
  • C Offline
    C Offline
    Clark Kent123
    wrote on last edited by
    #1

    I have been searching here in the VB forum for some clarification which I was unable to get. So if I have missed something that has already been posted please point me in the proper direction. I am upgrading some software from VB6 to VB2008. According to the free "Upgrading Microsoft Visual Baisc 6.0 to Microsoft Visual Basic .NET" book states in chapter 11 page 241 that for Left, Right, Trim, Mid, etc can return a NULL in the VB6 environment. However, in .Net this is not allowed for a string to contain a Null value. One of the suggestions the book and migration tool suggests is to use the "$" after the function. Example: Left$, Right$, you get the point. My question to all you out there is should I be doing what the book suggests to add the "$" to these functions prior to running the migration wizard that comes in VB2008? Are null strings still not allowed in VB2008 or future .net frameworks? Or is adding the "$" a waste of time? Can someone please give me some clarification if I am on the right path by updating these functions prior to the migration? Thanks in advance!

    D 1 Reply Last reply
    0
    • C Clark Kent123

      I have been searching here in the VB forum for some clarification which I was unable to get. So if I have missed something that has already been posted please point me in the proper direction. I am upgrading some software from VB6 to VB2008. According to the free "Upgrading Microsoft Visual Baisc 6.0 to Microsoft Visual Basic .NET" book states in chapter 11 page 241 that for Left, Right, Trim, Mid, etc can return a NULL in the VB6 environment. However, in .Net this is not allowed for a string to contain a Null value. One of the suggestions the book and migration tool suggests is to use the "$" after the function. Example: Left$, Right$, you get the point. My question to all you out there is should I be doing what the book suggests to add the "$" to these functions prior to running the migration wizard that comes in VB2008? Are null strings still not allowed in VB2008 or future .net frameworks? Or is adding the "$" a waste of time? Can someone please give me some clarification if I am on the right path by updating these functions prior to the migration? Thanks in advance!

      D Offline
      D Offline
      Dave Doknjas
      wrote on last edited by
      #2

      .NET strings can certainly be 'null' ('Nothing' in VB). The point the author was making (checking my own copy of that book), is that the old VB6 functions accepted arguments that may be Nothing, while the ones with $ after it did not. After upgrading to VB.NET, the VB.NET versions of those functions will throw an exception if you pass Nothing to them. For this reason, he suggests to try to isolate the issues before upgrading. Either way, you'll have to go through this, but the more issues you can resolve before upgrading, the less overwhelming the upgrade will be. I did a number of upgrades for clients a few years ago and I can tell you that this is true (and the book you're using is excellent).

      David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

      N C 2 Replies Last reply
      0
      • D Dave Doknjas

        .NET strings can certainly be 'null' ('Nothing' in VB). The point the author was making (checking my own copy of that book), is that the old VB6 functions accepted arguments that may be Nothing, while the ones with $ after it did not. After upgrading to VB.NET, the VB.NET versions of those functions will throw an exception if you pass Nothing to them. For this reason, he suggests to try to isolate the issues before upgrading. Either way, you'll have to go through this, but the more issues you can resolve before upgrading, the less overwhelming the upgrade will be. I did a number of upgrades for clients a few years ago and I can tell you that this is true (and the book you're using is excellent).

        David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

        N Offline
        N Offline
        Nagy Vilmos
        wrote on last edited by
        #3

        IIRC In VB6, if a string is assigned Empty, it just reverts to a zero length string "". I am sure you cannot assign Nothing to a string.


        Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

        1 Reply Last reply
        0
        • D Dave Doknjas

          .NET strings can certainly be 'null' ('Nothing' in VB). The point the author was making (checking my own copy of that book), is that the old VB6 functions accepted arguments that may be Nothing, while the ones with $ after it did not. After upgrading to VB.NET, the VB.NET versions of those functions will throw an exception if you pass Nothing to them. For this reason, he suggests to try to isolate the issues before upgrading. Either way, you'll have to go through this, but the more issues you can resolve before upgrading, the less overwhelming the upgrade will be. I did a number of upgrades for clients a few years ago and I can tell you that this is true (and the book you're using is excellent).

          David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

          C Offline
          C Offline
          Clark Kent123
          wrote on last edited by
          #4

          Thanks David. I appreciate that. This clarification helps me now how to navigate through all these string modification functions. Thanks again.

          M 1 Reply Last reply
          0
          • C Clark Kent123

            Thanks David. I appreciate that. This clarification helps me now how to navigate through all these string modification functions. Thanks again.

            M Offline
            M Offline
            MicroVirus
            wrote on last edited by
            #5

            The $ were added to add some explicit typing. In VB6, almost all library functions use variants (object references) rather than an explicit type; even if the argument in question only ever accepts a string, the parameter was still declared without a type. Adding the $ to the Left/Right/Mid functions forced their type to string, so they accept and return only a string. Apparently (I did not know this), the non-string versions accepted a Nothing value for the objects they were passed? This surprises me, as VB6 always raised an error when nothing was passed.

            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