473,383 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

String Problems

Hi, im having a couple of problems with strings. When i
use this code.

Dim Data(numBytes) As Byte
_Socket.Receive(Data)
TempData = System.Text.ASCIIEncoding.ASCII.GetString(Data)

The string it returns is always in this format "String
and i cant understand why it is not in the
format "String" could someone explain what is going on?
Its a bit annoying because i can compare strings.

Thanks

James
Nov 20 '05 #1
4 1061
"James Proctor" <an*******@discussions.microsoft.com> schrieb
Hi, im having a couple of problems with strings. When i
use this code.

Dim Data(numBytes) As Byte
_Socket.Receive(Data)
TempData = System.Text.ASCIIEncoding.ASCII.GetString(Data)
The line above is actually
System.Text.Encoding.ASCII.GetString(Data)
but it is the same.

I guess you know that ASCII is 7-bit only?
The string it returns is always in this format "String
and i cant understand why it is not in the
format "String" could someone explain what is going on?
Its a bit annoying because i can compare strings.


Probably a chr(0) within the string. The IDE displays only the part on the
left of chr(0), but the string contains more chars.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
-----Original Message-----
"James Proctor" <an*******@discussions.microsoft.com> schrieb
Hi, im having a couple of problems with strings. When i
use this code.

Dim Data(numBytes) As Byte
_Socket.Receive(Data)
TempData = System.Text.ASCIIEncoding.ASCII.GetString

(Data)
The line above is actually
System.Text.Encoding.ASCII.GetString(Data)
but it is the same.

I guess you know that ASCII is 7-bit only?
The string it returns is always in this format "String
and i cant understand why it is not in the
format "String" could someone explain what is going on?
Its a bit annoying because i can compare strings.
Probably a chr(0) within the string. The IDE displays

only the part on theleft of chr(0), but the string contains more chars.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

.

I should probs have explained that i see "String instead
of "String" when i debug the program and put the mouse
over the varible. It seems strange. It must be something
im missing out.

JP

http://www.ebmis.co.uk
Nov 20 '05 #3
"James" <ja**********@ebmis.co.uk> schrieb
I should probs have explained that i see "String instead
of "String" when i debug the program and put the mouse
over the varible.

Yes, that's how I understood your question. I think my answer covers this
issue. Maybe *I* missed something?
It seems strange. It must be something
im missing out.


--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4
James,
As Armin suggested, you have a chr(0) in your string!

More then likely because your data array is one byte too long, remember that
numBytes in:
Dim Data(numBytes) As Byte
Is the high bound, not number of elements!

Try
Dim Data(numBytes - 1) As Byte

Hope this helps
Jay

"James" <ja**********@ebmis.co.uk> wrote in message
news:0b****************************@phx.gbl...
-----Original Message-----
"James Proctor" <an*******@discussions.microsoft.com>

schrieb Hi, im having a couple of problems with strings. When i
use this code.

Dim Data(numBytes) As Byte
_Socket.Receive(Data)
TempData = System.Text.ASCIIEncoding.ASCII.GetString

(Data)

The line above is actually
System.Text.Encoding.ASCII.GetString(Data)
but it is the same.

I guess you know that ASCII is 7-bit only?
The string it returns is always in this format "String
and i cant understand why it is not in the
format "String" could someone explain what is going on?
Its a bit annoying because i can compare strings.


Probably a chr(0) within the string. The IDE displays

only the part on the
left of chr(0), but the string contains more chars.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

.

I should probs have explained that i see "String instead
of "String" when i debug the program and put the mouse
over the varible. It seems strange. It must be something
im missing out.

JP

http://www.ebmis.co.uk

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Susan Baker | last post by:
Hi, I have declared a class MyClass in a header file MyClass.h I have then gone onto define the class in MyClass.cpp. This is (roughly) what the definition (.cpp) file looks like: #include...
17
by: Olivier Bellemare | last post by:
I've tried to make a function that returns the middle of a string. For example: strmid("this is a text",6,4); would return "is a". Here is my code: char *strmid(char *texte, int depart,...
18
by: Steve Litvack | last post by:
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
10
by: zahy[dot]bnaya[At]gmail[dot]com | last post by:
Hi, I am trying to come up with a c style string reverser, I want it to take 1 argument Altough I would never do this in real life. Is there a way to do it? I wrote this function that fails : ...
3
by: sernamar | last post by:
Hi, I have the following base class class UnitOfMeasure { public: //... std::string& GetName() {return _uomName;}; //... protected:
42
by: =?Utf-8?B?UGxheWE=?= | last post by:
I have an if statement that isn't working correctly and I was wondering how I check for a blank string. My Code Example if me.fieldname(arrayIndex) = "" then ----- end if When I do this and...
3
by: ommail | last post by:
Hi I wonder if regular expressions are in general sower than using classes like String and Char when used for validating/parsing text data? I've done some simple test (using IsMatch()) method...
14
by: Javier | last post by:
Hello, in which cases is it better the use of "const char*" to "string" (or even const string &). I mean, in STL (http://www.sgi.com/tech/stl/hash_map.html) I see: hash_map<const char*, int,...
21
by: phpCodeHead | last post by:
Code which should allow my constructor to accept arguments: <?php class Person { function __construct($name) { $this->name = $name; } function getName()
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.