Length of String Returning HEX??? Weird

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

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
 
* (e-mail address removed) (Joe) scripsit:
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???

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.
 
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 ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top