Jump to content

Recommended Posts

Posted

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? :huh:

any help will be appreciated! :)

Posted

What's the desired functionality? Should the user begin the process? Should the file be determined by the user?

Posted

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.

Posted

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??

Posted
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.

Posted
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.

Posted

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 :(

Posted

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

Posted

Umm... try this

        Dim X As String = My.Computer.FileSystem.ReadAllText("FileHere")
        X = X.Replace("Word", "NewWord")

Posted
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.

Posted

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

Posted
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... :huh:

english please? lol

I'm *very* new to programing and i have no clue what you mean??? <_<

  • 3 weeks later...
Posted
ummm... :huh:

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

Posted

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... ;)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...