H@L0_F00 Posted October 8, 2008 Share Posted October 8, 2008 So I started messin with VB about a month ago but a made one program and kinda put it to the side I need help with a simple word replacer for program I'm attempting to code I was wondering if i should use the openfiledialog to actually open the text file or if i should just use streamread? any help will be appreciated! :) Quote Link to comment Share on other sites More sharing options...
mavrck Posted October 9, 2008 Share Posted October 9, 2008 What's the desired functionality? Should the user begin the process? Should the file be determined by the user? Quote Link to comment Share on other sites More sharing options...
dr0p Posted October 9, 2008 Share Posted October 9, 2008 The OpenFileDialog control just helps the end users navigate to the file, rather than have to enter the path manually; it doesn't actually do any of the reading. Quote Link to comment Share on other sites More sharing options...
H@L0_F00 Posted October 9, 2008 Author Share Posted October 9, 2008 I think I kinda worded it wrong sorry lol yes the user begins the process and determines file. but if i use openfiledialog and they open a file will it be inaccessible by the streamreader since its already open?? Quote Link to comment Share on other sites More sharing options...
dr0p Posted October 9, 2008 Share Posted October 9, 2008 I think I kinda worded it wrong sorry lol yes the user begins the process and determines file. but if i use openfiledialog and they open a file will it be inaccessible by the streamreader since its already open?? No, because, again, the OpenFileDialog control doesn't actually open the file. Quote Link to comment Share on other sites More sharing options...
H@L0_F00 Posted October 9, 2008 Author Share Posted October 9, 2008 ahhhhh thanks!! so i could use something like this? Dim text as new system.io.streamreader(openfiledialog.filenname) Quote Link to comment Share on other sites More sharing options...
dr0p Posted October 9, 2008 Share Posted October 9, 2008 ahhhhh thanks!! so i could use something like this? Dim text as new system.io.streamreader(openfiledialog.filenname) Yes, that's exactly how you'd do it. Quote Link to comment Share on other sites More sharing options...
H@L0_F00 Posted October 9, 2008 Author Share Posted October 9, 2008 got it! thanks! :D still got another problem though... i want it to be able to count how many instances of a word/string it finds and i have no idea how to even begin writing that :( Quote Link to comment Share on other sites More sharing options...
dr0p Posted October 9, 2008 Share Posted October 9, 2008 Eh... there's probably a better way at doing this but... For i = 1 To Len(sString) sTemp = Mid(sString, i, Len(sFind)) If sTemp = sFind Then 'add to list End If Next i sString = Input String sTemp = Temporary Variable sFind = String You're Looking For Quote Link to comment Share on other sites More sharing options...
Angablade Posted October 11, 2008 Share Posted October 11, 2008 Umm... try this         Dim X As String = My.Computer.FileSystem.ReadAllText("FileHere")         X = X.Replace("Word", "NewWord") Quote Link to comment Share on other sites More sharing options...
dr0p Posted October 11, 2008 Share Posted October 11, 2008 Umm... try this         Dim X As String = My.Computer.FileSystem.ReadAllText("FileHere")         X = X.Replace("Word", "NewWord") *sigh* You can totally tell I suck at .NET lol. Quote Link to comment Share on other sites More sharing options...
H@L0_F00 Posted October 14, 2008 Author Share Posted October 14, 2008 hahaha thanks anyways dr0p!! I probably would have done the same thing! :) il post the final .exe and source when im done Quote Link to comment Share on other sites More sharing options...
m0u53 Posted October 14, 2008 Share Posted October 14, 2008 if anything multithread your program maybe putting the file read/write/ into functions and use CreateThread() ..umm idk how that works in .NET but ..yea use threads/fibers Quote Link to comment Share on other sites More sharing options...
H@L0_F00 Posted October 14, 2008 Author Share Posted October 14, 2008 if anything multithread your program maybe putting the file read/write/ into functions and use CreateThread() ..umm idk how that works in .NET but ..yea use threads/fibers ummm... english please? lol I'm *very* new to programing and i have no clue what you mean??? <_< Quote Link to comment Share on other sites More sharing options...
Tarbizkit Posted November 4, 2008 Share Posted November 4, 2008 ummm... english please? lol I'm *very* new to programing and i have no clue what you mean??? <_< simultaneous operations. think of multi threading like a cable splitter, you have one input but multiple outputs Quote Link to comment Share on other sites More sharing options...
Steve8x Posted November 4, 2008 Share Posted November 4, 2008 Multi-Threading is a technique that programmers use to make their applications faster! Imagine you have one function that executes code and does two things one after the other... That code is running in 1 thread... If you split it up into two threads, you can get the job done faster. You'll have two running threads simultaneously. However if the first thing has to be done before the second, then you wont be able to make it two threads since you need the output from the first block of code before you can run the second... Make Sense? A search on google for "Threads" gives this as the second result... http://en.wikipedia.org/wiki/Multi-threading I don't code in VB though so I wouldn't be able to help you with the code.. C++ ftw... ;) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.