| | |
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; 21 Days Ago at 12:20 am.
0
#2 21 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 |
"crystal .net .net2005 30minutes 2008 access add application arithmetic array assignment basic binary box button buttons center click code combo combobox component connectionstring convert cpu data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel exists firewall folder image images isnumericfuntioncall login math memory mobile module ms msaccess mssqlbackend mysql navigate net opacity pan peertopeervideostreaming picturebox picturebox1 port print printpreview problemwithinstallation project record regex reports" reuse right-to-left save savedialog search serial sorting sqldatbase storedprocedure string temp textbox timer txttoxmlconverter updown useraccounts usercontol usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vbnet view vista visual visualbasic visualbasic.net visualstudio web wpf xml






