Posting Lines From A Text File (test Scores) Into An Array?
Oct 31, 2011
I need assistance with posting lines from a text file (test scores) into an array. From there, I'll have to average the test scores, find the standard deviation (without using the built in function) and assign grades based on the test scores' deviation. I have already written the code for the user to search and upload a text file. And I should be able to do the standard deviation of the array, if someone can help give me an example of how to send the text file to array and average the lines of the array without using the built in math functions.
[Code]...
View 15 Replies
ADVERTISEMENT
Jan 13, 2012
I'm basically trying to do a small report card project. I only need to pull 5 Students with each student having 5 Test Scores a piece. The full Code of what I have for the submit button is below. I have actually 3 questions.
1. I always seem to have trouble with them unless I initialize them when I dim them. Is there a better way than below
2. The below code works really well for Student 1 and all 5 test scores. Rather than do that code 5 times though, what is the best way for me to basically state that IF dblStudent1(intMax) = 4 Then Change dblStudent1(intMax) to dblStudent2(intMax) etc.
3. Would this be better suited towards a multidimensional array ?
Private Sub btnEnterGrades_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnterGrades.Click
Dim strStudentNames() As String = {" ", " ", " ", " ", " "} ' Holds the 5 Students Names
Dim intMax As Integer = (4) ' Place Holder for Student Number
[CODE]...
View 8 Replies
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
Mar 26, 2009
I'm trying to do is to read the lines from a text file, and transfer them to an array.[code]...
View 3 Replies
Oct 26, 2009
reading a text file into an array after a certain line in the text file, at the moment i am trying to do it using the method below: but i am having trouble thinking about how i can copy everyother line and also how i can count through the array the i = 0 and i = i + 1 are there while "i".
In a line what i would like to do:I need to copy everyother line for a known amount of lines that appears after the line " I FT I KT I " in a text file, but i do not know the position of this first line in the file.
Dim lines() As String = File.ReadAllLines(sessionsPath$ & "vmcg.afm")
For Each inline As String In lines
If inline.Contains(" I FT I KT I ") Then
[code]....
View 7 Replies
Sep 27, 2009
I am adding line entries in a .ini file. The problem is, I am creating duplicate lines in the file, which I do not want to do. I searched this issue online, and the consensus is to use an array, loop through for duplicates and create a new file. However, being so new at this and teaching myself how to code no less, I am at a dead end. This is not a school project, it is something I am doing for work on my own time. I have all of my code done for the program except for this last step.
[Code]...
View 7 Replies
Dec 12, 2009
I am trying to turn data in a text file seperated by spaces into a 2D array.
It is for a math game. The data is statistics based on the performance of the user. One line looks like this "John Doe 0 0 1 3 0 6 0 22"
I need to put the line into an array and then be able to search by name to display the results. I keep getting extra spaces in the input of the array so the data isnt where it should be. It seems that the first entry works correctly, but appended lines do not enter correctly.
Sub ResultsToFile()
Dim FILE_NAME As String = "C:\Student_Results.txt"
Dim RecordString As String = NameForm.PlayerFirstName & " " &
[Code].....
View 12 Replies
Jun 10, 2011
I am using streamreader to read and streamwriter to write, I have put the lines into an array
[text file contents]
Remove [ ] *****************
-----
;this is -----
------
;this is another -----
[end of example file]
I want to remove the lines that start with "****" and keep deleting lines until i reach ";" I thought this would be simple but im missing something and I don't want to put this array into a listbox it is being writen to a text file.
View 2 Replies
Dec 6, 2009
I have made it so my code will print out the average score of all the test as one. but for each student i need to have an average score.
Public Class frmMain
Structure TestScores
Public decTest1 As Decimal
Public decTest2 As Decimal
[code].....
View 5 Replies
Mar 15, 2012
As you will see from the code below I need to be able to tell before the array runs how many members of the array there are or else the program will crash. How can I redim the array depending on how many lines are in the text file (RECORDS.txt)
Imports System.IO
Public Class Form1
Structure Nation
Dim name As String
Dim continent As String
[Code] .....
View 2 Replies
Dec 23, 2011
As you will see from the code below I need to be able to tell before the arrayruns how many members of the array there are or else the program will crash. How can I redim the array depending on how many lines are in the text file (RECORDS.txt
Imports System.IO
Public Class Form1
Structure Nation
[code]......
View 6 Replies
Nov 25, 2010
I am working on an assignment for my Programming Logic and Design class. I also noticed a couple other similar posts but after going through them I still have an issue. I was suppose to write a program that will allow input of three test scores, average them then display a letter grade in a box. At this point the only thing that is being displayed is "F". [code]
View 3 Replies
Nov 19, 2010
I need someone with patience and can go through a solution with me from the Clearly Visual Basic book. I'm good with computers and can usually learn things relatively fast on my own time and in my own way, but I'm going to school for computer programming and, with certain things, I learn better with things explained to me rather than reading from a book. If someone has the time to go over this solution I'm doing and explain it to me in a way I'd have a better chance of understanding, I'd be truly grateful. I need a tutor, for lack of a better word. The lab I'm doing is from the Clearly Visual Basic book and the instructions are:
Code an application that displays a letter grade based on the averages of three test scores. Code the application using a function to determine and return the letter grade. If the average is at least 90, the grade is A. If the average is at least 80 but less than 90, the grade is B. If the average is at least 70 but less than 80 the grade is C. If the average is at least 60 but less than 70, the grade is D. If the average is below 60, the grade is F.
[Code]...
View 17 Replies
Jul 22, 2011
I'm having an issue with sending textfiles line by line on a timer.Currently I can pass a textfile location to my program, and on each tick it will send the first line, or the whole thing line by line. What I want to do is have my program pass line 1 of the text file on the first tick, and line 2 on the second tick, etc.LocationTB is where the user passes a file location.
ElseIf RadioButton2.Checked = True Then
Dim FILE_NAME As String = LocationTB.Text
Dim TextLine As String
If System.IO.File.Exists(FILE_NAME) = True Then
[code].....
View 1 Replies
Sep 30, 2009
I am a new user to VB and I am having difficulty with one of my assignments. The assignment states that to create an application that allows a user to enter three test scores each for three students. The application should calculate each student's average test score and assign a letter grade. The application should prompt the user for each student's name and three test scores.
[Code]...
View 3 Replies
Feb 8, 2012
I'm not sure where I'm going wrong with this. it's supposed to let the user add scores to the list, then calculate the total, average, and count. However, it doesn't let me add more values to the list. Any help whatsoever would be awesome! Keep in mind, I am new to VB and programming languages, and was just playing around with code hoping for any sort of positive result, and therefore some of the code may not be necessary, or make sense. Here's what I have now:
[Code]....
View 2 Replies
Jul 7, 2011
Create a program which promps the user to enter an unlimited number of test scores. The program should show the high score and the low score. You should use a loop of your choice within this program. The program should look similar to the one below:
View 3 Replies
Dec 1, 2011
I am trying to read in high scores from a text file that look like this
Name1
Score1
Name2
Score2
Name3
Score3
etc.
I can write them out fine, but reading them in I seem to be having a problem with. I have read in the first name ok but when I try to read in the second name, it is giving me the 3rd name. Code below
[code]...
Can somebody please explain why lblName2 is becoming the fifth line of text instead of the third? I realise I have probably not used the correct type of variables
View 4 Replies
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
Jan 27, 2011
I want to write a quick program that fills a 2D array with quiz scores. Consider there is 5 Students and each have completed 3 Quizes. I want the program to display a class average as well as a student average.
I've gotten as far as a nested for/next loop but I am stumbling over the language for accumulating and displaying the average.[code]...
View 2 Replies
Apr 27, 2010
basically i am doing something like:
vb
TextRenderer.DrawText(g, mc_Text, MyBase.Font, New Rectangle(Padding.Left, Padding.Top, MyBase.Width), MyBase.ForeColor, TextFormatFlags.WordBreak)
And want to get an array of lines where the text breaks with since TextFormatFlags.WordBreak has been set
View 3 Replies
Apr 9, 2011
Is there a way to make an array from all the lines within a file?
For instance, value 1 of array is line 1 of file, etc.
I found a way on Google, but for some reason if a line says something like: http://domain.com/file/file.exe
It will cut off the line to something like: http://domain.com/file/fi
View 2 Replies
May 2, 2011
I'm working on a program that when you click a button called new it pops up a new form asking for you to enter a directory location. If the directory exists it saves it into this file:
"C:WindowsSettingsButtonVariableSaves.ini"
I already have working code that saves each directory entered into the ini file on its own line.
Now in this code I'm trying to call each variable back from the ini file when form1_loads and set it to an array called ary() so later I can set the first 10 saved within the array.
So later:
button1.text = ary(1)
button2.text = ary(2)
and so on to
button10.text = ary(10)
and the reason I set the array to record all lines even if theres more than 10 because I want to be able to add more buttons later on.
Here's my current code for saving lines to an array:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim FILE_NAME As String = "C:WindowsSettingsButtonVariableSaves.ini"
[Code]....
View 2 Replies
Jan 4, 2012
I want to read each line from a txt file, but instead of using a for, while etc loop i will let the web browser do it (document completed). I want to increment the next line and let the loop continue till its finished.
Just say the data was inside a textbox, i'd do Textbox1.Lines(count) for line one, then i'd do count += 1 and when the web browser has completed, it would start again and repeat the process.
So how do i read the lines from a txt file into an array without looping? And allows me to specify the line number?
View 11 Replies
May 12, 2009
i have 5 textboxes in a form. I have a streamwriter that writes all of their text to on text file like this:
Code:
Dim xfile As String = Application.StartupPath & "/Set.txt"
If File.Exists(xfile) = True Then
Dim writex As StreamWriter = New StreamWriter(xfile)
[code]....
I was wondering how to get the text under the each number and place it in the corresponding textbox.
View 5 Replies
Jun 23, 2011
I'm trying to read lines from a file and split them into two words contained in a two dimensional array. The file looks something like this:
dog cat
red blue
orange green
night day
[code]....
'When I run it, it highlights the following line and says Object reference not set to an instance of an object
pos(i, 0) = value(0)
pos(i, 1) = value(1)
i = i + 1
Loop
[code]....
why I'm getting this error?
View 2 Replies
Nov 14, 2011
I know this is very basic stuff dealing with arrays, I have been messing this for a while and I'm not getting anywhere.I have a file with a list of 20 number 0-100. I am trying to get a text box to display the number of scores above average when a button is clicked.Using the same file I also need a list box to display the number of A's, B's, C's, D's, and F's, when another button is clicked.
View 10 Replies
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
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
Apr 2, 2010
I've got myself a CSV file with the following contents:
1,The Compact,1.8GHz,1024MB,160GB,440
2,The Medium,2.4GHz,1024MB,180GB,500
3,The Workhorse,2.4GHz,2048MB,220GB,650
It's a list of computer systems, basically, that the user can purchase.I need to read this file, line-by-line, into an array. Let's call this array csvline().The first line of the text file would stored in csvline(0). Line two would be stored in csvline(1). And so on. (I've started with zero because that's where VB starts its arrays). A drop-down list would then enable the user to select 1, 2 or 3 (or however many lines/systems are stored in the file). Upon selecting a number - say, 1 - csvline(0) would be displayed inside a textbox (textbox1, let's say). If 2 was selected, csvline(1) would be displayed, and so on.
It's not the formatting I need help with, though; that's the easy part. I just need someone to help teach me how to read a CSV file line-by-line, putting each line into a string array - csvlines(count) - then increment count by one so that the next line is read into another slot.So far, I've been able to paste the numbers of each system into an combobox:
Using csvfileparser As New Microsoft.VisualBasic.FileIO.TextFieldParser _
("F:folderprogramnameprogramnameinDebugsystems.csv")
Dim csvalue As String()[code]......
But this only selects individual values. I need to figure out how selecting one of these numbers in the combobox can trigger textbox1 to be appended with just that line (I can handle the formatting, using the string.format stuff). If I try to do this using csvalue = csvtranslator.ReadLine , I get the following error message:
"Error 1 Value of type 'String' cannot be converted to '1-dimensional array of String'."
If I then put it as an array, ie: csvalue() = csvtranslator.ReadLine , I then get a different error message:"Error 1 Number of indices is less than the number of dimensions of the indexed array."
Structure systemstructure
Dim number As Byte
Dim name As String[code]............
View 3 Replies