Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27223

How to create textbox/button combos to edit parts of certain lines in .text files

$
0
0
Hi,

I'm trying to build a simple level/mission editor for a PC game i have using VB 10.0. I'm pretty much a beginner with VB although i've done some basic database design and development with VBA about 5 years ago. I'm doing this as much as a learning experience as anything and hope that there will be people on here who are willing and able to help?

The game uses various .text (not .txt) files to define various parameters for each level and to edit these i would need to access these files and be able to input new text into some of the existing lines. These lines are in macro blocks and the files obviously contain slightly different text for each different level/mission. The ability to edit existing text would be useful too.

The .text files reside within 4-5 different folders within the root game folder and there is some cross-relation between some of the files i.e. changes in a text string in one file need to be reflected in another or several of the others.

I'm looking at using a form/forms with several constant textboxes to input the new text with associated buttons to execute the code that would make the changes to the lines in the files based on the content of the textboxes.

The research i've done so far seems to point to StreamReader and StreamWriter methods or possibly DataGridView or ReadAllText/WriteAllText?

Below is an short example of the type of files i want to edit/append:

loc_eng()
{

txt_cm_camp_stu_1() { Tigers in the Mist; }

txt_mc_sbmission_1() { We Attack at Dawn!; }

txt_history_sb_1() { This is my second mission.; }

}

}

The bold text are examples of what i might want to edit and as stated some of these edits would need to ideally be automatically carried out on another file/files if possible to avoid duplication of the same process. Ambitious i know but i'm really just fishing to see what the art of the possible might be?

One suggestion i've received from another forum is:

Dim strFile As string = IO.File.ReadAllText("c:\File1.txt")
strFile = strFile.Replace("oldvalue", "newvalue")
IO.File.WriteAllText("c:\File1.txt", strFile)

Another option i've considered is a form with text boxes that allows entry of the variable text and button that creates the file from scratch in the format shown above. In this case only the text shown in bold would be entered into the textboxes and the remainder would be automatically created "around" those values on creation of the file.

Any help or advice most appreciated?

Many thanks.

Viewing all articles
Browse latest Browse all 27223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>