Finding Min/max Lengths Of Lines In .txt File Without Arrays?

Mar 27, 2012

I am working on a program that opens a .txt file, finds the length of each line in the file, and then outputs the minimum and maximum lengths. For example, assuming this is the .txt file I am opening:

2789304
293048203
27598493

[code].....

I would like to return something like this:

Minimum length: 6
Maximum length: 9

I cannot use arrays for this assignment. I figured out how to get the maximum length but cannot figure out how to get the minimum. Am I going about this the right way or is there an easier way to do this? Here is what I have thus far:

Dim FileName As String
Dim FileReader As StreamReader
Dim FileLine As String

[code].....

View 4 Replies


ADVERTISEMENT

Create A Multidimensional Array That Contains Arrays Of Different Lengths?

Jan 1, 2011

Is there any way to create a multidinensional array that contains arrays of different lengths (similar to nesting arrays of different lengths in python).

Because if I were to declare a variable Dim accounts(2,2) As Integer all 1D arrays at each dimension have the same length. Is there any way to create an array so that this is not the case?

e.g The above code would create an array like this:
[[0,0],[0,0]]
but would it be possible to create this:
[[0,0],[0,0,0]]

View 3 Replies

.dat File With Certain Fixed Field Lengths Work Like A SQL Database In VB?

Mar 25, 2009

For a school program, I was assigned to use a .dat file to store and edit information while using VB to be it's front end( to appear in a listbox). I was also given what field length to use per field. I never worked with .dat files, so I have a few questions (all the google-ing Ive done say the same thing: every .dat file is different so you can't play around with them):

[Code]...

View 4 Replies

Pattern Finding In Files Using Byte Arrays And Multiparted Patterns To Search ?

Nov 28, 2011

As a continuation of my other thread, "Finding A Pattern without a string Array (http:[url]....)", I would like to continue asking questions about enhancing a scanner with a few things:

1. Here is my code for finding signatures in a file:

'First the Signature Class:
Interface Signature
End Interface[code]......

View 2 Replies

Read Lines In A File - Split The Lines And Spit The Result To Another File?

Aug 3, 2009

I am trying to make a script to spit command lines to a bat file to compress a bunch of files singly and then delete the original ones. I am sure that is easy to most of you, but I living a ____ trying to do this. A have a file list like this one belo, which was created with a command -- Dir /b /s /a-D N: > filelist.txt

[Code]...

View 2 Replies

Read Lines In A File, Split The Lines And Spit The Result To Another File?

Oct 20, 2009

read lines in a file, split the lines and spit the result to another file

View 2 Replies

Get A Bunch Of Lines From A Text File (they Will Be Filenames Eventually) Which Are Split By New Lines And Puts Each One Into An Array?

Jun 22, 2010

I have written a simple script to get a bunch of lines from a text file (they will be filenames eventually) which are split by new lines and puts each one into an array..

Dim ary() As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If My.Computer.FileSystem.FileExists("C:MenuFiles.txt") Then

[code]....

The only thing I can do for now is either use the substring function to remove the first character from all array values after 0 but I don't like that because it's messy and what if the split "works" as I want it to one one of the lines and knocks of the first character when I don't want it to.

View 1 Replies

Read Lines From Txt File After Every 7 Lines .net?

Mar 17, 2012

below are a few lines from my text file(10929 lines)I need to read each line and insert into MS Access. each line is a column in my table and the record changes on every 8th line or to be more specific(on every 8th line you will see a number [1,2,3,4,5,6,7,8,9.....] this is where another record starts,

[Code]...

View 15 Replies

Read Lines From Text File 1 And Delete Those Lines From Text File 2?

Sep 15, 2009

I have a text file containing lines of data (File 1). I need to delete all the lines in another text file (File 2), which are found in file 1.So I could read file 2 line by line. And then once the line has been read, read file 1 line by line to search for a match. But that's going to be painfully slow.Or I could read file 2 into memory. And then read file 1 line by line and REPLACE the lines in file 2 with nothing, therefore deleting them. File 2 could be 100 mb, so I'm not sure about reading it all into memory.

View 16 Replies

Allow Multiple Lengths On A Textbox?

Nov 18, 2010

I think this will be better than what I was thinking before.

How can I allow multiple lengths to a textbox.Allow multiple lengths on a textbox?

something like

if Not TextBox1.TextLength = 8 Or 11 Or 14 Or 18 Then msgbox("error")

View 5 Replies

Asp.net - Multiple Lengths For Substring?

May 17, 2012

Can a substring have mutiple arguments? I am pulling a substring from a drop down list into my database for records, the string is between 6 and 8 numbers, is it possible to pass more than one argument to make this work?

Sample data:

DropDownList
123456 | Name
1234567 | Name

[Code]....

View 2 Replies

Extract The Numbers Which May Be Random Lengths?

Apr 20, 2011

Forgive me but i have a noob question, I cant seem to get my head around.I have a textbox.text string as "111.1, 22.2, 3333.3, 444.44" What I want to is extract the numbers which may be random lengths, but all separated by a comma to

dim i1st number as Integer
dim i2nd number as Integer
dim i3rd number as Integer
dim i4th number as Integer

I know how to search for one instance of a string in a string but taking the 1st part to the comma, then the next comma and so on is confusing me.

[Code]...

View 2 Replies

Have To Go To Crazy Lengths To Just Compare Two Dates?

Sep 3, 2010

Basically I'm just trying to see if the date/time of files have changed on files.So I've got code something like this:-

Dim fi_source_CreationTime As DateTime = fi.CreationTime
Dim file_info_DateCreated As String = '** LOADED from a file **
If (fi_source_CreationTime = CDate(file_info_DateCreated)) Then

[code]....

View 21 Replies

How To Calculate Angles Of Right Triangle Given Lengths

Apr 5, 2011

I'm working on a Pythagorean Theorem program that calculates the sides and angles of a right triangle. I have the side measurements and all that down, but I can't find the Visual Basic function that will allow me to calculate the angles from the side measurements. I've tried asin and sinh, but both give me the wrong measure.

View 2 Replies

Sisplit The Text Into 48 Char Lengths?

May 9, 2011

simple loop code to split a text which is displayed on the text box. All that will need to do is split the text into 48 char lengths.

View 11 Replies

Sort Array Of Strings By Their Lengths?

Apr 4, 2012

I have an array of strings such as "blue", "green", "red" and I wish to sort them so the longest string comes first and the shortest last.

Currently I am creating another array with the lengths of each string in the array in the same index positions and using this array as the key array to sort by as can be seen below, but I think this could be optimised into one line perhaps?

Dim colours() As string = {"blue", "green", "red"}
Dim colourslength() As Integer
For i As Integer = 0 To colours.Length - 1

[Code].....

Edit: just realised I defined colours as a list in the example code, it's an array in my actual code.

View 4 Replies

Why Is Textbox String Changing Lengths

Feb 26, 2012

I am working on a project that I scroll from one screen to another.

A particular string I have 2 variables that can be changed. If I stay on this screen I can change either variable just as I need

however when I change to another screen then return my string is 1 digit longer and when I wish to edit this string my program fails because the string isn't the expected length.

A portion of my program follows....The Y6 is just a counter. The MA is a conditional control.

ElseIf _
Y6 = 4 _
And MA = True _

[Code]....

Delete 0-27 then determine whats there "NC" or "NO" and simply change it. But again when I leave this particular screen and return my text length is no longer 29 charactors long, it is now 30 charactors.

View 10 Replies

Write The DS Into A Txt Fie With Predefined Field Lengths?

Jul 30, 2009

I want to write the DS into a txt fie with predefined field lengths.

Code:Dim ds As New Data.DataSetda.SelectCommand = New SqlCommand da.SelectCommand.Connection = conn da.SelectCommand.CommandText = "SELECT * from Samp1" da.Fill(ds, "S1")

[Code]...

View 8 Replies

File I/O And Registry :: Multidimensional Arrays - Save File/Load File?

May 13, 2012

I'm currently developing an editor for an AFL management sim.I want to be able to load three or four multidimensional arrays to the program, then save them to the same file. I tried the tutorial on here but got completely muddled up. Why can't it be easy like in VB6 When it was like 10 lines of code tops!

View 5 Replies

Loop Through String And Split Into Equal Lengths

Feb 1, 2008

I have a string which can be of any length. I want to loop tthrough this string and if there 53 characters assign that to Variable1, then loop round again and assign the next 53 characters or less to variable2 etc etc until the end of the string. Ideally I would not want to split words - but that is another problem.....

View 10 Replies

File I/O And Registry :: Finding A Specific File Based On A Variable Name?

May 15, 2009

I will have a directory of files (IFO, BUP, and VOB; DVD files for anyone who cares), I need to find the first one by sorting these like this: Filter out everything that does not have a .VOB in it, then find the one like this VTS_**_1.VOB. It will always have a "1" before the extension, but the two numbers before that change, lastly I need that file returned as a variable.

View 4 Replies

Finding The Path Of A File That Was Opened With The Open File Dialogue?

Jun 5, 2009

Is there a better way of finding the path of a file that was opened with the open file dialogue? This is what I did. It works, but it seems like there should be a way to get the path through one of the open dialogue options.

Code:
'm_PicSource = OpenFileDialog1.FileName
'm_PicSource is a global var
Dim strCnt As Integer = m_PicSource.Length - 1

[Code].....

View 6 Replies

C# - Compare Multiple Arraylist Lengths To Find Longest One?

Jan 17, 2012

I have 6 array lists and I would like to know which one is the longest without using a bunch of IF STATEMENTS."if arraylist.count > anotherlist.count Then...." <- Anyway to do this other than this?

Examples in VB.net or C#.Net (4.0) would be helpfull.

arraylist1.count
arraylist2.count
arraylist3.count
arraylist4.count
arraylist5.count
arraylist6.count

DIM longest As integer = the longest arraylist should be stored in this variable.

View 5 Replies

VS 2005 Read A Text File / Pick Specfic Lines And Save As Different File

Oct 7, 2009

I a very large text document, I need to read some lines and at the end of each line, insert a text from the header of each page to he preceding lines.I have the following code the reads the file and displays it on a list box.Public Class Dialogs..[code]

View 2 Replies

File I/O And Registry :: Deleting Lines In A Sequential Text File?

Mar 22, 2009

I know that Deleting a specific line in a sequential text file is impossible but instead copy the needed lines and not copying the unneeded ones to an output file .. killing the old one and renaming the new one with the same.. I can't make this step...

That is my record file

Code:
Input #1, CustomerName, CustomerHomeAddress, CustomerBussAddress, CustomerTel1, CustomerMob1, CustomerID, DateRent, CarRegPin

Code:
"Josek Sam","68 West Land Street","149 Union of States","4524563","45635463","JOSKSAM1",#2009-03-02#,"MILANCGLZ2008"
"Josef Malm","142 Unions Street","64 Hamersters Street","452504","42542054","JOSFMALM2",#2009-03-06#,"MILANCGLZ2008"
"Dave Green","131 Oxford Street","96 BlueBane Route","452542452","43254345","DAVGRN3",#2009-03-07#,"MILANCGLZ2008"

I made a form that when you put your CustomerID in Text3 Box.. it access the records and make some calculations. now.. The customer will return the car.. Then his data should be deleted.. I want to know how to make that when I enter the CustomerID and press on the Command button .. It copies the other lines to a new output folder and doesn't copy these ... So it appears to be deleted using this way..

View 3 Replies

Folder/file Processing - Open A .txt File And Add The Extra Lines To It?

May 13, 2010

what im trying to do and what i have done so far is probably a little backwards not sure sure how to id it any other way.when the user generates an error because a particular file doenst exist ive got my dialoge box to generate an .txt file for each file it errors on, so that the administrator can check and update missing files as an when - shouldnt be many files missing in the first place, should just be new product ranges or item just launched.what im stuck on is:

1. is there a better way

2. how do i open a .txt file and add the extra lines to it, so i re use the file but keeping the previous data.

View 2 Replies

Adding Txt-file With App And Finding It On Another Pc?

Nov 6, 2011

I need my published vb 2008 application to open a helpfile that I wrote. It is a simple .txt-file and this piece of code does the trick as long as the program is not published because I already know where I placed the Helpfile:

System.Windows.Forms.Help.ShowHelp(Me, "C:Helpfile.txt", HelpNavigator.TableOfContents)

After it is published on another pc, the helpfile is not on the root of the c-drive but in the application folder of the program. However, I can not know where the path to the program folder of someone else's pc is. It all depends on where they decide to place the program when they install, right?

It seems I need to replace this little: "C:Helpfile.txt" with some code that searches all the drives and directories and/or points directly to the Helpfile's placement - i.e. the parent directory of the program.

View 16 Replies

Finding A File And UnauthorizedAccessException?

Aug 19, 2011

I am trying to search a drive letter (C drive) for a file in Vb.Net 2010. After I find the file path I want to run the executable. This is the code I am trying to use to find the file:

path = Convert.ToString(IO.Directory.GetFiles("C:", "wswc.exe", System.IO.SearchOption.AllDirectories))

[code].....

View 2 Replies

VB6 Used Recordsetsor Arrays - .Net Framework In VB2010. Datasets, Dataviews. Tableadapters, Arrays. Enums ?

May 9, 2010

In VB6 I load a recordset containg all of the records (6 fields per record)in a table into an XArray and then manipulate the records in the array and then write them back to the original table. The array issorted by the first field (1 to maybe 8000 or more) I need to find records in the array by an ID field and then move them (because of some external criteria that happens many times) from say number 400 to number 375. Then all of the other records between 375 and 399 were renumbered up 1 to fill the gaps left by the move.

The XArray worked well as it could find and also move to a next record easily to facilitate the revisions to each record quickly. Everything is done in VB6 in code and nothing visual needs to be shown to the user until say 2000 of these external changes are complete. What is the best, most efficient way to do this in the .Net framework in VB2010. Datasets, Dataviews. tableadapters, arrays. enums ?

View 3 Replies

Integer Arrays - User Enter In Big Integers Using - Two Parallel Arrays

Dec 10, 2009

My assignment is to have a user enter in big integers using what i think is two parallel arrays. I got this far but now im stuck. I think i need to actually convert the text box input into an array but i do not know how to do that. I am all over the place in this project.

'Created/ Revised by: Jessica Falcetta
'Cap 204 Final Project: Big Integer Project
'Project Purpose: To calculate large integers through parallel arrays

[CODE]...

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved