Changing Lines According To User Input In Text File

Jul 1, 2009

I have lines in my text file like this:
x y
x Y
x y
x y
x y
x y
x y
x y
x y
x y
x y
x y
x y
x y
x y
x y
x y
x y
x y
x y

Lets say I have 20 lines like this. I want to change this lines according to user input. So user will input how many lines they want to change in terms of row and column. In my program
Row=TextBox5.Text column=TextBox6.text
User must enter initial value for x and y. Let say the initial value is
x=1 y=1.
Row=2 column=5..

Now my lines should look like this.
1 1
2 1
3 1
4 1
5 1
1 2
2 2
3 2
4 2
5 2
x y
x y
x y
x y
x y
x y
x y
x y
x y
x y

Since I enter row=2 only two set of lines is change other lines remain unchange. But in my coding all the lines is changing like this:
1 1
2 1
3 1
4 1
5 1
1 2
2 2
3 2
4 2
5 2
1 3
2 3
3 3
4 3
5 3
1 4
2 4
3 4
4 4
5 5
which is wrong.

This is my code
Dim lines() As String = IO.File.ReadAllLines("C:\wirematches.txt")
Dim xValue As Decimal = Val(TextBox1.Text)
Dim yValue As Decimal = Val(TextBox2.Text)
Dim altValue As Decimal = 2.54
Dim lineTracker As Integer = 0
[Code] .....
This code working fine for changes the column. But i dont know where i should write the code for row.

View 7 Replies


ADVERTISEMENT

Changing Lines In A Text File?

Feb 17, 2010

Is there a way to specify where in an open file a program is supposed to look (like specifying the current line)?

I'm using FileOpen(1, path, OpenMode.Input)

to open the file, but i need to jump from place to place in it

Here's what i'm trying to accomplish:

I'm trying to navigate round in a file containing questions for a quiz game, but am having no luck.

The general form is like this

**********
~(tile)~(question)~(answer)~
~(tile)~(question)~(answer)~
~(tile)~(question)~(answer)~

[Code]....

View 5 Replies

Take A Static Stream Reader And Switch It To Another Text File Based On The User Changing The File?

Mar 10, 2010

Is there anyway to take a static stream reader, and switch it to another text file based on the user changing the file?

View 1 Replies

Create A Text File With The Name Coming From User Input

May 23, 2010

E.g The user enters data into txtName, what i then want to do is make a text box with the data entered into txtName

So if the User enters Daniel into txtName, then a txt File is created called "Daniel.txt"

View 3 Replies

Save User Input From Multiple Textboxes To Text File?

Sep 18, 2010

Is there a simple way to save user input from MANY controls (textboxes, comboboxes, etc...) to a text file? When I say 'MANY', I am referring to at least 580 textboxes and several dozen comboboxes.

I may be able to accomplish this using the StreamWriter Class, but doing this individually would take quite a long time. I suppose I could also change all text boxes to richTextBoxes and save to .rtf. It seems like this would be even more time consuming.

Surely there is a simpler way to do this 'globally', perhaps with an added single line of code that points (and saves) to a preset or created text.txt file whenever text is added or changed in a textbox or combobox throughout the program.

View 7 Replies

Pull A Random Word From A Text File And Check Against User Input?

Apr 19, 2011

I need to pull a random word from a text file in my resource folder (visual Studio 2010) and then have a user enter a letter to see if it is in the word. Yes, Hangman game. There is more, but right now I need to pull from that text file for a start. I know what I have is not even close to right under "Get Word Button", but I'm kind of confused about the process.

Public Class hangMan
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim word As New Random
End Sub

[code]....

View 2 Replies

Creating User Input With Textbox.text Input Then Displaying In Messagebox?

Feb 19, 2012

If my Category and Forum selection is incorrect I am sorry and feel free to move it. I'd like to have the users input in the message box that will show. For example: There is a textbox and the user puts in their name as Bob. Then the message box would be: What my main goal is, is being able to include the users input they type inside the textbox inside the message box.

View 6 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 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

Call Two Lines From VB Script And Give The Same In .bat File As Input?

Jun 3, 2011

how to call two lines from VB Script and give the same in .bat file as input.

Here is my VB SCript code..
Set oShell = CreateObject( "WScript.Shell" )
Set ObjFSO= CreateObject("Scripting.FileSystemObject")
Str1="Version=3.1016.0.0"

[Code]....

View 9 Replies

Search A CSV File By An Input String And Return All Lines That It Is Found?

Dec 12, 2009

I was hoping someone could assist with the following coding; I am trying to search a very large csv file (approx 200,000 lines) for a user defined string eg "0100020789" and I essentially want to print all the lines that contain this to a text box on screen. Please not that the csv file does not have standardised column headings, each line is different. There would be approx 5 lines that contain the input string.

I am concerned with the v large csv i am using which will prob slow everything down, but then I thought if simple text pad application can search for a string in complete files with similar sizes like that and return a result in less than 1second, then it must be do-able.

View 1 Replies

VS 2008 : Stopping A User From Entering Text Or Changing Text In A Textbox Without Disabling It?

Apr 26, 2009

A] Is there any way of stopping a user from entering text or changing text in a textbox without disabling it or

B] Is there a way of changing the texboxes back and fore color whilst it is disabled?

View 5 Replies

Read Individual Lines Of A CSV File Into A String Array, To Then Be Selectively Displayed Via Combobox? Input?

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

User To Be Able To Search It By Changing The Text Property?

Nov 8, 2010

I am looking for a code exmple. I have a data combobox and I want the user to be able to search it by changing the text property.

View 3 Replies

Allow User To Input A Phrase Into A Text Box?

Apr 20, 2010

Alright. I have a project I need to complete by 11:00 am today. I need a program that will allow a user to input a phrase into a text box. Another text box to input a letter. Then I need the program to count how many times, the letter appears in the phrase. I have everything set up. I know how to count how many characters are in the string, but not how many designated letters there is.

View 5 Replies

Not Allowing User Input In Text Box

Feb 13, 2012

I am using a text box to display a list of items in which I want to be for reading only. Is there any way that I can not allow user input into this text box? Right now I have the text changed set to show an error message, that works but the text entered before the message box appears, still shows.

View 6 Replies

Use To Email One Text Box's User Input Like A Name

Feb 13, 2011

What code would you use to email one text box's user input like a name. I have tried so hard for this but after 3 hours of stress I finally have decided to come here. This project is causing a lot of stress and I can't believe that these simple things are getting me

View 2 Replies

Making A File That The User Doesn't Have Access To And Changing The Location Of The Configuration File?

Jun 25, 2011

on my program i have an activation in it and in order to activate the program you need to enter a code that is stored in the settings. so i was looking through my computer and i found the programs config file. and so I opened it and i found all of the codes for the activation. I need to find out how to make the file so the user doesn't have access to it and then how to move it to a more hidden place in the C: drive.

View 3 Replies

File I/O And Registry :: Read One Text File And Put Lines In Different Text Boxes?

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

Convert User Text Input To Command

Dec 15, 2009

is there a way to accept user input and convert those inputs into command? e.g. i have a textbox that can "test" commands. when i type this into the textbox, it should run the command:

dim a = "asd"
msgbox(a & "fg")

View 2 Replies

Highlighted Text Treated Like User Input?

Aug 4, 2009

I have code to go through a document highlighting letter by letter:

Private Sub Timer1_Tick( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If Not RichTextBox1.SelectionStart < RichTextBox1.TextLength Then

[Code]...

View 1 Replies

VS 2008 User Input From A Text Box Into Code?

Apr 14, 2010

How do I get numbers typed into a text box to be feed into my code and then the code to be ran?Below is the code that I want the information from a text box to be fed into. With the (0, 50) being the numbers.I will have a form set up like this, A button labeled Generate. 3 Text boxes total, 2 of them side by side with one being low and one high. For example The user will input 5 in the low box at 100 in the high box. Hitting generate the numbers will then be inserted into code and the result being shown in the 3rd text box.

Now what is the code that I'm looking for that will help me take information from TextBox1 and TextBox2 and insert into the (XXXX, XXXX) field in my buttons code?

View 3 Replies

Drawing With VB - User Must Make A Series Of Figures Such As Rectangles, Text Boxes And Lines

Oct 19, 2011

I'm doing a web application in which the user must make a series of figures such as rectangles, text boxes and lines, Is something like like google docs draw

View 2 Replies

Convert User Input Text Into Vb.net Executeable Code?

Mar 13, 2010

I know there are work-arounds like using a Select Case, but in my situation, it would make things a lot easier... especially since I won't know exactly what will be entered. I can't force the user to use a combobox or anything like that either, because it is going to be unique code for every situation. If there is no way of doing this, I will figure something else out, but it will require a lot more work.

View 1 Replies

Get The Try/catch To Work With Text Boxes And Input From The User?

Feb 4, 2010

I'm familiar with Visual C# and the try/catch for that but I cannot seem to figure out how to do the same thing in VB. Basically I can't figure out how to get the try/catch to work with text boxes and input from the user and whatnot.I've tried setting the textbox.text property = "" but that has no use, I've been trying to find something on Google about it but I cannot seem to find a single thing about textbox try/catch statements. Is it possible to do it with text boxes?

View 5 Replies

Text Box Formatting - Force User To Use Specific Type Of Input

Dec 16, 2009

I have a text box labled QTY, which feeds the QTY column on a datatable. the table then is ran through a function that takes the data and converts it to a string which my production machine can read. My problem is this, and its probably really simple (these problems usually are) how to i force the user to use a specific type of input on the txtbox so they would have to put the QTY in the format of 01 02 03 etc etc, i have it set to default to 00 but i want to force the user to haver to input 2 chars.

View 5 Replies

Saving A HTML File With User Input As File Name?

Sep 18, 2011

Currently the reports are saved as a html file called report1.html, id like to make the user enter a name for the HTML file upon clicking submit.

A little stuck on how to make the filename for the HTML file save to a input entered by the user.

I currently have:

Try
'Open new HTML file to be written
WriteHtml = New StreamWriter(Application.StartupPath & "ListHardware.html")
If Not (WriteHtml Is Nothing) Then ' Is the File Open

[Code].....

View 4 Replies

Create A Function To Remove Dirty Words From User Input Text?

Sep 15, 2009

I am trying to create a function to remove dirty words from user input text and want to replace those dirty words with four ****. In my scenario , i have list of dirty words where i would iterate the input user text and want to replace. Say for example.,

Dim InputTxt As String = "hi bush how are you.... $hit and @ss"
Dim OutPut As String = " hi **** how are you... **** and ****";

Problem: It works fine to replace some word like " bush" however fails in the below function doesn't replace "$hit" and "@ss".

Note: I do not want to use string.Replace because it doesn't have word boundary in the sentence..

Public Function pReplaceWords(ByVal dirtyWord As String, ByVal inputText As String, ByVal options As RegexOptions) As String
Try

[Code]....

View 10 Replies

Retreiving Data From Excel With User Defined Input That Is In Text Format?

Jul 7, 2011

The problem is I am able to extract the data by giving cell reference like: TextBox1.Text = objWorksheet.Cells(5, 2).value

But I want to select a row as per input given by user and want to extract data from that row.

The input given by user is in text format, in my case name of employee. And I have to extract address of that name.

[code]...

View 1 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







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