Length of String Returning HEX??? Weird

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joe

    Length of String Returning HEX??? Weird

    Hi,
    When I get the length of a string I expect to get an integer back. I
    getting back &H6 for both intVar1 and intVar2 from the following code:

    Dim strVar As String
    Dim intVar1 As Integer
    Dim intVar2 As Integer

    strVar = "foobar"

    intVar1 = strVar.Length
    intVar2 = CStr(Len(strVar ))

    Could someone PLEASE tell me what I'm doing wrong???
    Thanks

    - Joe
  • Brian Davis

    #2
    Re: Length of String Returning HEX??? Weird


    Check to see if you have "Hexadecima l display" turned on under
    Tools->Options->Debugging->General.

    Brian Davis




    "Joe" <problemchild19 70@gmail.com> wrote in message
    news:fe1bacf.04 08261454.1ff970 ff@posting.goog le.com...[color=blue]
    > Hi,
    > When I get the length of a string I expect to get an integer back. I
    > getting back &H6 for both intVar1 and intVar2 from the following code:
    >
    > Dim strVar As String
    > Dim intVar1 As Integer
    > Dim intVar2 As Integer
    >
    > strVar = "foobar"
    >
    > intVar1 = strVar.Length
    > intVar2 = CStr(Len(strVar ))
    >
    > Could someone PLEASE tell me what I'm doing wrong???
    > Thanks
    >
    > - Joe[/color]


    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Length of String Returning HEX??? Weird

      * problemchild197 0@gmail.com (Joe) scripsit:[color=blue]
      > When I get the length of a string I expect to get an integer back. I
      > getting back &H6 for both intVar1 and intVar2 from the following code:
      >
      > Dim strVar As String
      > Dim intVar1 As Integer
      > Dim intVar2 As Integer
      >
      > strVar = "foobar"
      >
      > intVar1 = strVar.Length
      > intVar2 = CStr(Len(strVar ))
      >
      > Could someone PLEASE tell me what I'm doing wrong???[/color]

      Where do ypu get this results? If you are talking about the IDE's
      "Watch" window, simply right-click the value and select "Decimal format"
      (translated from the German version of VS.NET) from the context menu.

      '&H6' is only another "representation " of the variable's value. The
      variable itself stores 6 in 'Integer' format, not as a string. So,
      inside the application it doesn't make a difference whether hexadecimal
      or decimal display is selected.

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

      Comment

      • Hal Rosser

        #4
        Re: Length of String Returning HEX??? Weird

        question about the code -
        1. doesn't "Cstr" return a String data type ?
        2. Isn't intVar2 an Integer ?
        3. Are you assigning the String output of Cstr to intVar2 ?
        4. do you have option strict off?
        ---what would happen if you removed "Cstr" from that last line of code ?

        "Joe" <problemchild19 70@gmail.com> wrote in message
        news:fe1bacf.04 08261454.1ff970 ff@posting.goog le.com...[color=blue]
        > Hi,
        > When I get the length of a string I expect to get an integer back. I
        > getting back &H6 for both intVar1 and intVar2 from the following code:
        >
        > Dim strVar As String
        > Dim intVar1 As Integer
        > Dim intVar2 As Integer
        >
        > strVar = "foobar"
        >
        > intVar1 = strVar.Length
        > intVar2 = CStr(Len(strVar ))
        >
        > Could someone PLEASE tell me what I'm doing wrong???
        > Thanks
        >
        > - Joe[/color]


        ---
        Outgoing mail is certified Virus Free.
        Checked by AVG anti-virus system (http://www.grisoft.com).
        Version: 6.0.744 / Virus Database: 496 - Release Date: 8/24/2004


        Comment

        Working...