By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,417 Members | 904 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,417 IT Pros & Developers. It's quick & easy.

Length of String Returning HEX??? Weird

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

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

Brian Davis
http://www.knowdotnet.com

"Joe" <pr**************@gmail.com> wrote in message
news:fe*************************@posting.google.co m...
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

Nov 21 '05 #2

P: n/a
* pr**************@gmail.com (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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3

P: n/a
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" <pr**************@gmail.com> wrote in message
news:fe*************************@posting.google.co m...
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

---
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
Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.