473,513 Members | 2,576 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Fixed length strings

<VBFixedString(50),
System.Runtime.InteropServices.MarshalAs(System.Ru ntime.InteropServices.Unma
nagedType.ByValTStr, SizeConst:=50)> Public BusinessName As String
txtBusinessName.MaxLength = Len(ludtTmp.BusinessName)

===snip

txtBusinessName is a textbox

Tracking down a problem lead to the above. Maybe it didn't work in VB6 - I'm
not sure.

But now Len returns 0 not 50 as I would like.

I've looked around the doc but can find no way of getting the max length of
the fixed length string

Is it possible??

Cal
Nov 20 '05 #1
3 1602
" active" <ac****@REMOVEa-znet.com> schrieb
<VBFixedString(50),
System.Runtime.InteropServices.MarshalAs(System.Ru ntime.InteropServices.Unma nagedType.ByValTStr, SizeConst:=50)> Public BusinessName As String
txtBusinessName.MaxLength = Len(ludtTmp.BusinessName)

===snip

txtBusinessName is a textbox

Tracking down a problem lead to the above. Maybe it didn't work in
VB6 - I'm not sure.

But now Len returns 0 not 50 as I would like.

I've looked around the doc but can find no way of getting the max
length of the fixed length string

Is it possible??


Yes, have a look at the code. It doesn't change at run-time. ;-)

Now, serious, maybe you can use reflection (namespace System.Reflection).
The VBFixedString attribute doesn't make the string's length is always 50.
The attribute is only used whenever you use the FilePut/FileGet procedures.
I don't know if there is a kind of Len function that does what you need. I
haven't found one.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
Nov 20 '05 #2
Now, serious, maybe you can use reflection (namespace System.Reflection).
The VBFixedString attribute doesn't make the string's length is always 50.
The attribute is only used whenever you use the FilePut/FileGet procedures.


I knew that. I just don't know anything about using Reflection and the
examples I looked at do not show me how immediately and I don't want to
digress so I made a set of constants that I use. (Run-on sentence??)

I was hoping someone knew an easy way.

Thanks,
Cal
Nov 20 '05 #3
" active" <ac****@REMOVEa-znet.com> schrieb

I was hoping someone knew an easy way.


Sorry, not me.
--
Armin

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

Nov 20 '05 #4

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

Similar topics

26
9637
by: Adrian Parker | last post by:
I'm using the code below in my project. When I print all of these fixed length string variables, one per line, they strings in questions do not properly pad with 0s. strQuantity prints as " 4". Six spaces than the value of intQuantity. This is correct. But all the others end up being string objects of only 6 characters long (with...
1
5503
by: Tajmiester | last post by:
Hi, And thanks for any help. I am having trouble declaring a struct containing strings that can be Serialized using the following functions. It works, but the strings wont store the right number of characters, they store one less with a null at the end! Whats the point in a marshalling as fixed length if it wastes space with a null! How can...
3
7647
by: ecov | last post by:
Is there any easy way to read into a dataset a file that was created from a BCP command. The file is in a fixed length format. I would also like to be able to write out a dataset to the same type of file structure. The obvious solution would be to use XML file processing however that is not an option as I have a third party vendor that...
3
1492
by: Ken Kast | last post by:
I'm using VBFixedString to create fixed length strings. But I find that the string will merrily allow a string of greater length to be assigned to it. Is this the way things are supposed to work? I've got a more basic question. The reason I'm doing all this is so I can pass a string buffer to an unmanaged method in a dll. It's assuming...
4
1933
by: LCAdeveloper | last post by:
I have had to move to Visual Studio.NET Pro. from Visual Basic 4.0 and am now starting to re-write our code. I was a bit surprised to find that Visual Basic.NET no longer supports fixed length strings, which is a pain as we use our own database format with specific, user-defined data types and random access files. An example module content would...
4
23789
by: Scott Lemen | last post by:
Hi, Some Win APIs expect a structure with a fixed length string. How is it defined in VB .Net 2003? When I try to use the FixedLengthString class I get an "Array bounds cannot appear in type specifiers" error. Thank you, Scott
3
4466
by: KLomax | last post by:
VB6 allowed you to define User types that you could write to file using the statement. This is a nice way to generate fixed length text files. See Below. VB.NET does not support UserTypes with fixed length strings in the same way. How do you do this in VB.NET? Thanks, Ken ============ Code Snipit ============
5
3095
by: David Garamond | last post by:
The MySQL manual recommends that we create a "fixed-length row" if possible, for speed (especially scanning speed). A fixed-length row is a row which is comprised of only fixed-length fields. A fixed-length field takes a fixed amount of bytes for storage (e.g. INT = 4 bytes, CHAR(M) = M bytes, etc). Is there a similar recommendation in...
4
2177
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 { public byte MsgType; public uint Tag; public fixed byte ID; public fixed byte Val1;
1
9401
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 form data in a fixed length structure that is written direct to disk. I need to load the existing files, into a fixed length structure to...
0
7270
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7178
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7565
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5704
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5103
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4759
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3255
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
473
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.