| | |
Convert 1-Dim String Array to String
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jun 2009
Posts: 4
Reputation:
Solved Threads: 0
I'm working on a mass text replacer program because I'm sick of all the 10-day trial ones out there that aren't very good.
The entire program is basically finished (All easy stuff), but now I need to code the actual replace/delete stuff, which I'm stuck on because apparently the way I originally intended to do it is not possible.
The way it works is you load a text file (.txt, .cfg, .ini, .doc, etc.) which opens a StreamReader which writes all the data into a listbox. Then you pick whether you want to replace or delete a string. If you select replace, then you enter the string to search for and in another textbox you enter the string to replace it with.
The way I originally intended to do this was like this:
The problem is, I believe this method requires txtfile, str1 and a1 to be strings, but they're all 1-dimensional string arrays, which cannot be converted to strings, or at least I don't know how to convert them.
A friend told me one way I could do this is to open both a StreamReader and StreamWriter and do the replace/delete line by line as they are entered into the memory and write them to a temporary file which is then copied over the original. I can do this kind of, but I still don't know the proper way of doing the actual replace code because the string to find and the string to replace with are still 1-dimensional string arrays rather than strings.
I can't think of any other way to do this, due to I'm not that experienced in VBNet. Any help is greatly appreciated.
The entire program is basically finished (All easy stuff), but now I need to code the actual replace/delete stuff, which I'm stuck on because apparently the way I originally intended to do it is not possible.
The way it works is you load a text file (.txt, .cfg, .ini, .doc, etc.) which opens a StreamReader which writes all the data into a listbox. Then you pick whether you want to replace or delete a string. If you select replace, then you enter the string to search for and in another textbox you enter the string to replace it with.
The way I originally intended to do this was like this:
VB Syntax (Toggle Plain Text)
If o1.Text = "Replace" Then 'The option Replace(txtfile, str1, a1) 'txtfile is the data, str1 is the string to find and a1 is the replacement End If
The problem is, I believe this method requires txtfile, str1 and a1 to be strings, but they're all 1-dimensional string arrays, which cannot be converted to strings, or at least I don't know how to convert them.
A friend told me one way I could do this is to open both a StreamReader and StreamWriter and do the replace/delete line by line as they are entered into the memory and write them to a temporary file which is then copied over the original. I can do this kind of, but I still don't know the proper way of doing the actual replace code because the string to find and the string to replace with are still 1-dimensional string arrays rather than strings.
I can't think of any other way to do this, due to I'm not that experienced in VBNet. Any help is greatly appreciated.
Last edited by Darkicon; 20 Days Ago at 12:20 am.
0
#2 20 Days Ago
Use Aggregate Method.
VB.NET Syntax (Toggle Plain Text)
Dim s() As String = {"AA", "BB", "CC"} Dim Str As String Str = s.Aggregate(Function(P, Q) P & " " & Q)
Failure is not fatal, but failure to change might be. - John Wooden
![]() |
Similar Threads
- data string to array (C#)
- String to array of char (C++)
- Converting a string array into an int from a text file (Java)
- Find string in array (VB.NET)
- convert string to array (Pascal and Delphi)
- Delete From String array (VB.NET)
- random string array (C++)
- String array (C++)
- How do I convert a vector to a String array ? (Java)
- Copy string into an array (C#)
Other Threads in the VB.NET Forum
- Previous Thread: Tab Control in VB.Net
- Next Thread: Web Browser Help.
| Thread Tools | Search this Thread |
.net .net2008 30minutes 2005 2008 access account arithmetic array basic bing button buttons center check code combobox component connectionstring crystalreport data database databasesearch datagrid datagridview date design dissertation dissertations dropdownlist excel fade file-dialog filter folder ftp generatetags google gridview hardcopy images input insert intel internet mobile monitor ms net networking objects output panel passingparameters peertopeervideostreaming picturebox picturebox1 port position print printing problem problemwithinstallation project save searchbox searchvb.net select serial shutdown soap survey table tcp temperature text textbox timer timespan toolbox trim update updown user vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf year






