472,984 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Fixed Size String

cvh
Hello,

In delphi I could do this :

Var Str: String[2] (String of size 2char)

How would I do this with VB.NET in CF?

Thank you,

Christophe
Nov 21 '05 #1
13 2340
"cvh" <Ch***@nomail.com> wrote in message
news:eI**************@TK2MSFTNGP09.phx.gbl...
In delphi I could do this :
Var Str: String[2] (String of size 2char)

How would I do this with VB.NET in CF?


Why would you need to?

Support for fixed length strings is available, but requires use of
the VB "Compatibility" Library, which may or may not be
supported in future releases of the Framework.

However, there are lots of other ways of handling this kind of thing.
What exactly do you need to /do/ with this fixed length string?

Regards,
Phill W.
Nov 21 '05 #2
"cvh" <Ch***@nomail.com> schrieb:
Var Str: String[2] (String of size 2char)

How would I do this with VB.NET in CF?


Simply assign a string with 2 characters length to a string variable :-).

--
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
Phill,

for this I am as well real curious for.

Why would you need to?

Cor
Nov 21 '05 #4
cvh
So making a string fixed size won't save RAM?
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
"cvh" <Ch***@nomail.com> schrieb:
Var Str: String[2] (String of size 2char)

How would I do this with VB.NET in CF?


Simply assign a string with 2 characters length to a string variable :-).

--
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 #5
cvh
A string is in memory as long as it is used in dotNet plus its reference of
course.

When it is changed than there will be made a complete new one and the old
one will be destroyed.

I hope this gives some ideas

Cor
Nov 21 '05 #6
"cvh" <Ch***@nomail.com> schrieb:
So making a string fixed size won't save RAM?


Why should it save memory? Fixed size strings make sense in some interop
scenarios, but in general it's better to stick with normal strings.

--
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 #7
Bob
Not that it's likely that you need it, but to technically achieve a fixed length string without
resorting to interop, you can use the old-school approach:

Dim SomeFixedLengthString As Char(2)
SomeFixedLengthString(0) = "h"c
SomeFixedLengthString(1) = "i"c

Or...

Dim SomeFixedLengthString As Char() = {"h"c, "i"c}

Just like in LISP. Man, that brings back memories. I hated using EMACS as a debugger...

Bob

"cvh" <Ch***@nomail.com> wrote in message news:eI**************@TK2MSFTNGP09.phx.gbl...
Hello,

In delphi I could do this :

Var Str: String[2] (String of size 2char)

How would I do this with VB.NET in CF?

Thank you,

Christophe

Nov 21 '05 #8
"Bob" <no***@nowhere.com> schrieb:
Not that it's likely that you need it, but to technically achieve a fixed
length string without
resorting to interop, you can use the old-school approach:

Dim SomeFixedLengthString As Char(2)
SomeFixedLengthString(0) = "h"c
SomeFixedLengthString(1) = "i"c

Or...

Dim SomeFixedLengthString As Char() = {"h"c, "i"c}


Still, this doesn't limit 'SomeFixedLengthString' to the type "String of
length 2". For example, if a class exposes a 'PrimaryLanguageCode' property
that should only accept strings consisting of two characters, you cannot
enforce that at compiletime. What you can do is throwing an exception in
the property's 'Set' part if a client tries to assign a shorter or longer
string.

--
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 #9
Herfried,

You can fix the length of a string (as long that you do not paste it in) in
a textbox.

What I hope explain direct the rest.

(I know that you know that as well)

Cor
Nov 21 '05 #10
I think you are just like me. I was facing a problem when I was writing a
conversion program to work with COBOL85. You can pad the string after you
assign the value:

http://msdn.microsoft.com/library/de...RightTopic.asp

chanmm

"cvh" <Ch***@nomail.com> wrote in message
news:eI**************@TK2MSFTNGP09.phx.gbl...
Hello,

In delphi I could do this :

Var Str: String[2] (String of size 2char)

How would I do this with VB.NET in CF?

Thank you,

Christophe

Nov 21 '05 #11
cvh
Thanks 4 the replies guys.
"cvh" <Ch***@nomail.com> wrote in message
news:eI**************@TK2MSFTNGP09.phx.gbl...
Hello,

In delphi I could do this :

Var Str: String[2] (String of size 2char)

How would I do this with VB.NET in CF?

Thank you,

Christophe

Nov 21 '05 #12
guy
a fixed length string ***might*** save memory, normally the word length you
are working with. so on current 32bit intel/amd cpus you will save 4 bytes
per string.
This mattered 25 years ago with 8 bit cpus and 64Kb memory, but now a few
bytes saved is worth nothing comapred to the development gain of not having
to worry about them

hth

guy

"cvh" wrote:
So making a string fixed size won't save RAM?
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
"cvh" <Ch***@nomail.com> schrieb:
Var Str: String[2] (String of size 2char)

How would I do this with VB.NET in CF?


Simply assign a string with 2 characters length to a string variable :-).

--
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 #13
Cor,

"Cor Ligthert" <no************@planet.nl> schrieb:
You can fix the length of a string (as long that you do not paste it in)
in a textbox.


That's true, but I don't see the relation to the OP's question ;-).

--
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 #14

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

Similar topics

6
by: Eric | last post by:
.... my eternal gratitude!!! :p Here is the problem. A sample of my original VB6 code : '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public...
4
by: taskswap | last post by:
I'm converting an application that relies heavily on a binary network protocol. Within this protocol are a lot of byte arrays of character data, like: public unsafe struct MsgAddEntry {...
0
by: Ken Varn | last post by:
I have a managed C++ assembly in which I need to interact with some 'C' APIs that take fixed size 'C' data blocks. I need to wrap these data blocks into a managed object. It seems like a lot of...
7
by: carterweb | last post by:
This is how I do it now. 1. Determine the dimensions of the rectangle. 2. Set a my font size to a fixed maximum size. 3. Apply the font my string and measure the string using the graphics...
1
by: O.B. | last post by:
In the example below, I'm trying to convert a fixed byte array to a string. I get an error about needing to use "fixed" but I have no clue where to apply it. Help? using System; using...
1
by: Rick Knospler | last post by:
I am trying to convert a vb6 project to vb.net. The conversion worked for the most part except for the fixed length strings and fixed length string arrays. Bascially the vb6 programmer stored all...
2
by: Jack | last post by:
Hi, I want to read a string a chars from a stream, and put it into a string. At the moment, I'm creating a buffer of a fixed size, and reading the stream of text into it. It works, but I have...
0
by: Jack | last post by:
Hi, I do a webrequest and it returns some text data in a stream. I want to put this tyext data into a string. I've got it working just fine, but I have to put the text data into into a...
4
by: Jack | last post by:
Hi, I do a webrequest and it returns some text data in a stream. I want to put this text data into a string. I've got it working just fine, but I have to put the text data into into a...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.