Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Setting Column In 2d Array To Fixed Length


I have a 2d array that has a number that designates a quantity

I need this field to be 5 characters long
putting the appropriate number of spaces at the beginning of the number

e.g.
" 1"
" -1"
" 111"
"11111"




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Array Of Fixed-length Strings
Hey all:

I need a large array of strings, about 8,000. But they only need to be 4 characters long each.

Does anyone know how to declare an array of fixed-length strings?

Thank you all.

Array In A Type Without Fixed Length! Help!
Hi I am making a file format into a type but unfortunately If I want to save the type to file I get extra data in it! how can I remove it?


Code:
Option explicit
Private Type resource
size As Long
data() As Byte
End Type
Private sub myexample()
dim examle as resource
Open "C:default.ico" For Binary Access Read As #1
example.size = LOF(1) '&H8BE
ReDim example.data(LOF(1) - 1)
Get 1, , example.data
Close #1
Open "C:default2.ico" For Binary Access Write As #1
Put 1, , example
Close #1
end sub


I get:
BE 80 00 00 01 00 BE 80 00 00 00 00 00 00 and then the data

But I need
BE 80 00 00 and then the data

In my case it's more complex! I have arrays in arrays in the type!

Please help! Thx.

Parsing Fixed Length Integer Array To A Sub?
I want to mimic the following C code in VB6:

Code:
void something(int myArray[3])
{
myArray[0] = 9;
myArray[1] = 8;
myArray[2] = 7;
}
In VB6, could I do the following to receive the same result?

Code:
Private Type intArray3
int0 As Integer
int1 As Integer
int2 As Integer
End Type

Private Sub something(ByRef myArray As intArray3)
myArray.int0 = 9
myArray.int1 = 8
myArray.int2 = 7
End Sub
Thanks.

[edit] Just realized I could use "ByRef myArray() As Integer". Would parsing it without specifying the size create any overhead compared to my original example using a user-defined type. The function's I'll be using this for requires a lot of CPU processing, so I'm curious about things like this.

Number Of Elements In A Fixed-length Array?
when declaring an array, it must be set with a constant value. ie, you can not do it like this:
Code:
Dim arrayDeck(1 To x) As String

and modify the length of the array by changing the value of x



is there a way of checking the number of cells containing values in the array? for example, if the array is 96 cells long but only the first 67 contain a value...
if the array is 96 cells long and being depleted from the upper end to the lower end

UBound(arrayDeck) returns the length of the array, always being 96.

How Do You Return An Array Of Fixed Length In A Function?
Private Function SocksHeader(mHost As String, mPort As Long) As Byte(9)

is basically what i want to do

but i get a compile error "Expected: ) "

Discussing Coding Style Of Non-fixed Length Multi-dimension Array
I have a number of experience on using 2 dimension array in VB,
I would like to know some better, and standard pattern to write it.

for an example,
We need to pass a set of patient record from a modules to a form,
this record include all the current male patients(no fixed length).
the record includes (name, sex, age)

Please give me advise and write down your coding style in this issue.
Thanks!!

Fixed Length For String
I have this code:


VB Code:
strAmount=Format(txtCampaignID, "000000")


If I enter 5 into txtCampaignID, strAmount will display 000005. However, if I enter ABC into txtCampaignID, it will only display ABC and not 000ABC.

Why is that? How can I get it so that it will display a fixed length string whether you enter a number or letters?

Ascii Fixed Length
Hi

I am trying to write a basic utility program that will read from an fixed length ascii file. I know how to read the file using this code:

Line Input #File1, LineBuffer
sName = Mid$(LineBuffer, 1, 12)
sAddress =Mid$(LineBuffer, 13, 21)

but I don't know how to select one line and ouptut it in different text file.

Fixed Length Files:

12345 John Doe 8514 Bingham Rd. Rockville MD. 25476
12346 Jack Frost 24 Cold Place North Pole AL. 19684

my ? is how to select the one line, say line 2 and copy that line into a another fixed length txt file?

Thanks in advance.

Alexxx

Fixed Length Font
Does anyone have a list of fixed length fonts?

Fixed Length Strings
I have a fixed length string that is getting a value out of
an ini file. The value in the ini file is empty and the
function is not setting a default value, I thought it
should. Also, if the value is "" (nothing) and it's fixed
length, how do i determine if it's empty?
Thanks for the help, here is my code.



Code:
Dim ProgramPath as String
Dim lngReturn as Long
Dim buf as String * 256
Dim strValue as String

ProgramPath = App.Path
lngReturn = GetPrivateProfileString("Section", _
"KeyName", "Default Value", buf, Len(buf), _
ProgramPath & "DirectoryFile.ini")

strValue = Trim$(buf)

'This is the part that's not working correctly.....
'It is fixed length but empty :(
If strValue <> "" then
'Do stuff
End if

Fixed Length String Value
Hi there,
What is the initial value of the following string?
Dim strTemp as String * 10


Thanks
maii


Fixed Integer Length?
I know I can have a fixed string (ex: Dim strThing as string * 20) but how can I do this with an integer (or any number taking one like long)?
So, for example, if the fixed length of integer i is 3 and i = 7 then i will actually be 007 (3 digits cuz fixed length of integer is 3)

Using Fixed Length Strings
What are the ramifications of using fixed length strings as opposed to variable?
In my application while parsing, I get a big cpu hit due to using variale strings.
The reason is that variable strings are continually getting re-allocated each time the string is changed, even with trim$.
If I input everything into *10 char strings, what problems will I encounter, eg, doing a string compare. Since the fixed length strings will now have blank characters appended to fill the string, compares will not be the same. Anything else to be aware of?

Exporting To Fixed Length
I have a set of data that I'm exporting to a text file. However the file is not in fixed length format. For instance, it looks like this:

"abcd","123 brwon street","Austin","TX"

When I need it to look like:

abcd 123 brown street Austin TX

Any ideas? Thanks in advance.

Fixed Length String
Hello

This is a silly question but it is driving me crazy.

Lets say I declare a fix length string like this

Dim sTest as String * 2

How would I test if it has been populated with a value other than the filler.


Thanks
P

Make A Cell Fixed Length
Is there a way to make the text within a cell fixed length? I only want to be able to enter up to 60 characters in a cell, but I cant find anything after searching this site and google.

Any suggesstions would be appreciated.

Thanks.

Numeric Condition As Well As Fixed Length
OK I wanted to know how can u set an if condition to be true if something is numeric as well as being no less than or bigger than 10 lengths?

Fixed Length Strings Problem
Hiya

I have a fixed length string which is 10 long. What is it padded out with when i pass a 3 digit value into it?

The reason I ask is because I need the spaces to be filled with something meaningful, for example if i enter the value 605 into it, i would like it to have a value of 6050000000 or 0000000605.

I tried adding the value "0000000000" with no luck, any ideas?

can anyone help?

many thanx

Fixed-length Strings In ODL Structure
I was wondering if anyone could tell me how to declare a fixed-length string in a structure defined in an ODL file that will be utilized by a VB application?

I know that in VB it's done as:

Code:
Type MyStructure
Element1 As String * 10
Element2 As String * 20
End Type

But what I would like to do is declare my structure in an ODL file. The structure is going to be used by more than one component of my application and I really don't want to have to declare it in each project. Hence my use of a Type Library.

Could you provide me with an example of how I might do this:

Code:
//Where <?> is the data type declaration.
typedef struct {
<?> Element1;
<?> Element2;
} MyStructure
Thank you.

How Keeping The Number Fixed Length
hey guys how r u ?
in my project i read from parallel port so some imes i read binary with zero in the left side, this Zero is important for me but when i read data and if it has zero at the left or more the lenght of the number will be less for example 01111111 will look like this 1111111 just 7 number(bits) and i want to have 8 bits

is there a way for this , i tried to make if statments but it doesn't work, is there a propertiy in the textbox that make the numbers or when converting number to string to keep the number in the same length


thankx

Maximum Fixed String Length
I bet this question has been asked before. I did a search but without success.
Well does anybody know what the maximum lenght of a declared fixed string is?

VB Help says that its "approximately" 65000.

I tried

VB Code:
Dim testString as String * 65535


It returns an error at runtime.


VB Code:
Dim testString as String * 65526

And not more works without error... why?

65536 - 10 ?

thanks for help

Matrix Display, Fixed Length?
Hello all,
I'm working on a control that has the Matrix type of Display, NOT the movie.

Currently, the scoll length is = to the numbers of characters being used. I would like to change it so that the display shows all the characters that will fit into the specified number of character placements.

For instance, if the displays width is about 3/4ths of the way across the form, I want it to display text across the same distance. So, if your text string is only 15 characters long, I want it to show those 15 characters as often as need be to cover the display.

Example:

"Hello there!!! Hello there!!! Hello there!!! Hello there!!! Hel"

Get what I mean?

See the attached file for more information.

Any help or advice is greatly appreciated,
Thanx,
ziggy2004

Getting Info From Fixed-Length Strings
Pretty simple question really. Just wondering how I can get a value from a fixed length string without having the series of chars (what are they anyhow? vbcr?) following it?

For example


Code:
Dim Songname As String * 30

'Songname is read from an mp3 file as "Song1 "
'those spaces arent spaces though, they're whatever that char is

strTitle = RTrim(Songname)


At the end of this ... strTitle still equals songname before it went through RTrim. Is there an easy way to get around this?

Cheers

Fixed Length String Questions.
VB 6.00 gave error for the following.
VB Code:
Private Function X(Value As Integer) As String*2
It wanted to terminate statement after As String, indicating that a Function is not allowed to return a fixed length string.

Is this true? A Function cannot return fixed length string?

BTW: I read a year or more ago that VB Net does not allow fixed length strings in any context. Is this still true? Is there a way around this in VB net? Any indication that VB net might be enhanced to allow fixed length strings?

Truncating Fixed Length Strings
what is the best way to truncate a fixed length string.
example

dim strTest1 as string * 15
dim strTest2 as string

strTest1 = "hello"
when i assign strTest1 to strTest2 it has the extra characters.

strTest2 =strTest1

whats the best way of making strTest2 without the fixed length characters.

thanks

Help With Fixed Length Text File
Hi ....

I need somebody to help me, I have a fixed length text file which is getting captured from a telephone log system, I need to read this file and show them on form...let say I have the following text file:

aa b1234 6789cd 0002 abc <--------- the first line
aa b1234 6789cd 0002 abc <--------- the second line
aa b1234 6789cd 0002 abc <--------- the third line
aa b1234 6789cd 0002 abc <--------- the forth line


aa is data1 ,then b is data2 1234 is data 3 , cd is data 4, 000is data5 , 2 is data 6 etc..

reading this and making queiry on it such as if data4 is cd then or if data4 is ef then.....that will be helpful.


Thanks again for any one who could help me.

Fixed Length Text Parsing
I need to parse a fixed length text file. The text file as multiple "records" each which span multiple lines. I have a layout of what field starts at what position and the size of the total field.

I have found resources that let me parse one line of fixed length text, but the crux of my situation is that one record, has multiple lines of text.

For instance:
AC013803832 D-John Doe DOT 4455
Morris Park SomeCity AB 55555 SCREEN
TC1039039893 png/ml 11/17/200111:20*00137
TE100891010

would be one record, and there are about 65000 such records in my text file.. I know when a record ends by the "TE..", the "TE" tells me that is the last line of one record. The next subsequent line will start with another AC.

I have to extract all the important stuff I need, store them into variables and insert them into an Access Database, which is trivial once I get the appropriate values stored in variables.

My problem is actually parsing through so many records in such an awkward format. Single line Fixed length text parsing I have done before, but when one record consists of multiple lines...I have no clue.

Any help is appreciated.

Thanks,
Blas

Dimming Fixed Length Strings
i'm writing an encryption program that separates a file into blocks...in which the number of blocks is in the form n ^ 2, so the number of bytes within each block are the length of the file / n ^ 2. I need to dim a variable for reading and writing bytes of a fixed length, which is the number of bytes within each block. i tried doing dim input1 as string * blocksize but that gave me an error saying that i needed a constant...not a variable. if there's any way to work around this, i'd really like to know. thx.

Read A Fixed Length File In VB
Hi,

Can anybody tell how to read a fixed length text file using VB code????? I want to read the data in that file and insert it into a database. Can anybody help me how to do this?

How To Make Fixed Length Log Files In VB
I wrote a VB6 application that automatically does a lot of low-level busy work for the user. It works great, but I am concerned about what would happen if it should ever crash. So I added a trace file that lists every action taken (write a line to a file, change a token with a specific value, etc.) That way, if it ever crashes, we can go back and see what the program did so we can patch things up.

To create the trace file, I just open the file for append and do line output commands from a log subroutine.

Of course, this file grows without limit (up to 2 GB, anyway). It's not a problem for the moment because the IT guy works for me. But I would like to make his life a little easier. Many applications have log files with a maximum size. When the maximum size is exceeded, the oldest information is lost.

I would like to set a maximum size for my trace file, but VB6 doesn't seem to have that ability. I went cruising through these forums and through the Windows API file functions, and I still didn't find anything. This is such a common requirement, I can't believe there isn't a "canned" answer (or at least an answer that doesn't require reading and writing the trace file every time.)

The application uses an access data base with ADO, but I rejected the idea of logging to the data base. One of the things I want to protect myself from is a corrupt data base. Sometimes, there's just nothing better than a nice dumb linear ASCII text file.

Does anybody have any suggestions?




Edited by - deichenlaub on 6/12/2005 11:59:02 AM

Matrix Display, Fixed Length?
Hello all,
I'm working on a control that has the Matrix type of Display, NOT the movie.

Currently, the scoll length is = to the numbers of characters being used. I would like to change it so that the display shows all the characters that will fit into the specified number of character placements.

For instance, if the displays width is about 3/4ths of the way across the form, I want it to display text across the same distance. So, if your text string is only 15 characters long, I want it to show those 15 characters as often as need be to cover the display.

Example:

"Hello there!!! Hello there!!! Hello there!!! Hello there!!! Hel"

Get what I mean?

See the attached file for more information.

Any help or advice is greatly appreciated,
Thanx,
ziggy

Matrix Display, Fixed Length?
Hello all,
I'm working on a control that has the Matrix type of Display, NOT the movie.

Currently, the scoll length is = to the numbers of characters being used. I would like to change it so that the display shows all the characters that will fit into the specified number of character placements.

For instance, if the displays width is about 3/4ths of the way across the form, I want it to display text across the same distance. So, if your text string is only 15 characters long, I want it to show those 15 characters as often as need be to cover the display.

Example:

"Hello there!!! Hello there!!! Hello there!!! Hello there!!! Hel"

Get what I mean?

See the attached file for more information.

Any help or advice is greatly appreciated,
Thanx,
ziggy2004

Variable Length Numbers Into A Fixed Field
I have a number coming from a table that can have a length of 1 to 19. I need to take this number and write it to a file that is fixed field. How can I painlessly count the number length and then assign the appropriate number of zeros to pad the number to a fixed length of 19? I'm really wanting to avoid some kind of if statement that check the length and assigns the right amount of zeros...19 times.

Thanks!
Bryan

Importing Fixed Length Text File Into SQL
HELLLP!
I have this table in my SQL db that has 571 columns. The data is in a text file that has fixed length fields, no delimiters.

I've tried three times to do the import using the wizard and keep missing one or two lines (to set the columns) and I end up with 569 columns or 570.

It takes me at least 45 minutes to do this each time and I'd like to try and speed things up as I have several similar text files to import.

I want to do something in vba (access) as I have a project set up with direct connection to the sql server and I know how to connect and do inserts and what not.

My problem is parsing out the lines in the text file. I have another table that specifies column name and length (that's what I used to create the big table).

How could I use that to write some code to parse through the text file?

I know how to do the inserts and loops and what not, it's just the parsing part, ie. how to access the text file, tell it where to start and stop for each column, that I don't understand.

Any help would be greatly appreciated.

And one more thing, now that I found this place I'll see if I can't help out a little too!

Converting Fixed Length Fields Into Access
Hi,

Anyone know the best way to convert old fixed length fields into an Access table. The fields where created using the old basic method of Get# and Put#.

Thanks,
met12

Halting User TextBox Entry To A Fixed Length
I am making some minor, last-minute improvements to the data editing routines in my application. I have two textbox fields that accept numerals (string format) for business ID and Project ID. Both codes are 5-characters long. Right now, the two textboxes for these fields can take more than 5 characters and this leads to an error in processing to the database because the field length is just 5 characters. What kind of code segment is needed to physically stop the user from entering more than 5 characters and to warn him/her that the field only can take 5?

Similarly, what code is needed to return the user back to the box that caused the error but with the original entry or a blank box there?

Thanks

Geoff

Detecting Null Kinda Value In Fixed Length Strings
I have an array of recors with fixed length strings in them,
I have added all these to a listbox.
As the string may not contain many values...
(the length is 60 characters but some entries are 5 for example)
i am writing an algorithm that temporarily stores only the "useful" characters in a string and then adding that to the listbox.
But i can't detect the spaces properly, can anyone see whats wrong with my code? sorry im heaps tired.


VB Code:
Open "C:mp3db.txt" For Random As #3 Len = LenB(Currentsong)totalrecords = (FileLen("C:mp3db.txt") / LenB(Currentsong))For b = 1 To totalrecordsGet #3, b, Currentsong h = 0Doh = h + 1tempstring = Right$(Currentsong.Artist, h)Loop While tempstring = ""artistedit = Left$(Currentsong.Artist, (60 - h)) h = 0Doh = h + 1tempstring = Right$(Currentsong.Title, h)Loop While tempstring = ""titleedit = Left$(Currentsong.Title, (60 - h)) listdisplay = artistedit + " - " + titleeditrecordlist.AddItem listdisplay, (b - 1)Next bClose #3

Public Fixed Length Strings In Class Modules
I need to use fixed length strings in a class module. From MSDN it says 'A Public fixed-length string can't be used in a class module.'
What is the best way around this? Do i just justify the string with blanks to make the length??

Thanks

Fixed Length Text File With Write # Statement
Need to output a recordset in a fixed length format to a text file using the Print# or Write# statement.

This is what I have so far but when the field is longer than what the tab allows it writes it on the next line instead of forcing it on the same line (or writing over the existing field) Please Help!!



Open "test3.txt" For Output As #1

While Not rs.EOF

Print #1, Tab(0); rs.Fields("Ship_To_ID"); Tab(14); rs.Fields("Ship_To_Name"); Tab(39); rs.Fields("Ship_To_Address_1");
Print #1, Tab(64); rs.Fields("Ship_To_City");



rs.MoveNext
Wend
Close #1

Upload Data I.e Fixed Length From Text File........
Hi All,
I am using VB6.0 and Access 97
I need to upload data from text file.
The text file dontains fixed length characters.
Ex:
0212130202010003 400.00 11 2 16287 201
0212130202010005 754.00 11 2 16287 201
0212130550020005 222.00 25 5 11448 5002

I am trying to use Split function........
sCama=""
MAX_COLUMN_INDEX =6
FileLength = FileLen("\Deposit Program" & FileExist)
       If (FileLength > 0) Then
           ConnectiondbOpen
             Open "\Deposit Program" & FileExist For Binary Access Read Lock Read As #FileNo
           sTemp = Space(FileLength)
         Get #FileNo, , sTemp
         Close #FileNo

         ' Split data into constituent rows
         strData = Split(sTemp, vbCrLf)
         For lngRow = 0 To UBound(strData)
            ' Split row into constituent columns
            strItem = Split(strData(lngRow), sCama, , vbTextCompare)
             If UBound(strItem) = MAX_COLUMN_INDEX Then 'The problem is here
                sDLN = strItem(0)
                cAmount = CCur(strItem(1))
                iNumChecks = CInt(strItem(2))
                byScanner = CByte(strItem(3))
                ..........................
                ...........................

It is not recognizing columns. And i don't know how to specify the seperator for fixed length strings.
[It's easy to specify , Or ; Or Tab]
Can somebody help me in specifying the seperator........
Thanks
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>







Edited by - sreddy on 3/3/2006 7:01:51 AM

Import Text File Using Fixed Length Delimeter
Hi All,
I was working on import text files to an flexigrid,
i have to provide the same way as in excel report i was able to import based on delimeters but when the fixed lengthdelimeter comes to picture i am finding it difficult expecting for immediate response from you friends.
It will be very much usefull the import using fixed delimeter is same as in Excel or if we use the import option in excel from VB application

Control For Importing Fixed Length Text Files
I am looking for a control similar to the Microsoft Access Text Import Wizard.

I need to give the user a graphical means of clicking field "begin and End" locations in a fixed-length record, and importing according to these offsets.

The user needs to be able to add, remove & move these place markers.

Surely there must be SOMETHING like that out there...

Can anyone help me??????

Export A Fixed Length Text File To Comma Delimited
Hi all

Does anyone know how to exprt a fixed length text file to comma delimited text file. I know that u have to check for characters in the text file , but i wouldnt even know how to do this .

Please can someone help

thanks

How Do You Remove Extra Spaces From Fixed Length Strings? *solved!*
I need to know if you can get rid of extra spaces from a fixed length string and just have the part with all the characters that you want in it. For example, if I had "I want a dog " then I would want "I want a dog".

Fixed Row And Column Color
Is the only way to color fixed rows on an msflexgrid to make them not fixed and code them accordingly?

MSHFlexgrid Fixed Column
I sure I'm just missing something easy here. I have a MSHFlexgrid that I have its datasource set to a recordset, everything works fine.
I have 1 fixed row, so my Column labels all stay locked at top.
The first column holds ComputerName. I would like to have it so that when someone scrolls to the right to see information on that ComputerName the ComputerName Column stay fixed.
I thought just settings a fixed Column would do this, but everytime I set that it just puts a blank column before all my data. Any help?

Thanks, Moat.

How To Change A Fixed Column?
Hi,

How can I resize a Fixed Column (which is the greyed first column) of MSHFlexGrid?

Thanks in advance.

Seema_S

Select Row With No Fixed Column
How can I select a row without having a fixed column?
Would I have to check for the mousedown in the first column and do it this way, or is there a better way?

Scrolling And Fixed Column
Dear all,

I have a pair of wideish ListView controls (View = lvwReport) on a Form one above the other they have the same column headers and width.

The top ListView contains a one reference data record. The bottom ListView contains records which are similar but which may not be the same; fields are coloured green if the same and red if different from the reference. The user can select multiple rows/ records in the lower Listview and opt to duplicate the reference record into them. All is working well however;

When the form width is changed the 2 ListViews widths are changed to fit inside it. When the width of the Listviews is less than the total width of their columns they display their horizontal scroll bars.

1. Is it possible to make both Listviews horizontally scroll (together) when the scroll bar for either is adjusted?

2. When the horizontal scroll bar is scrolled to the right the Listviews leftmost columns scroll out of view; is it possible to make the first column(s) fixed?

regards Hugh,

Copyright © 2005-08 www.BigResource.com, All rights reserved