Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Help me plz

Name: Anonymous 2009-05-18 0:49

I need some help doing this Visual Basic project.... I need to incorporate into my Notepad-like program a find/replace function. I already have the Replace all working fine, but I can't figure out how to make my find button a find + find next (ex. it finds one occurrence, you press it again and the next occurrence is highlighted) Here is what i gots so far.

a = txtSearchWord.Text

b = InStr(TextEditor.txtMain.Text, txtSearchWord.Text)

If b Then

TextEditor.txtMain.Focus()

TextEditor.txtMain.SelectionStart = b - 1

TextEditor.txtMain.SelectionLength = Len(a)

Else

MsgBox("Text not found.")

End If

Name: Anonymous 2009-05-18 0:51

Just include PCRE.

Name: Anonymous 2009-05-18 0:56

PCRE?

BTW a and b are strings

Name: Anonymous 2009-05-18 0:57

>>3
perl compatible regexes

Name: Anonymous 2009-05-18 1:05

Visual Basic
Now you have two problems.

Name: Anonymous 2009-05-18 1:10

To code the replace, you need to find the string in the first place. HIBT?

Name: Anonymous 2009-05-18 1:24

>>6
No, you just cannot read. :(

Name: Anonymous 2009-05-18 1:29

PLEASE USE THE CODE TAGS!!!

Name: Anonymous 2009-05-18 1:38

So, I still don't have anything.

Is there a way I can make it highlight all occurrences of the word?

Name: Anonymous 2009-05-18 1:44

If I help you, will you go away and never post your homework bullshit on /prog/ again?

Name: Anonymous 2009-05-18 1:45

Will do.

Name: Anonymous 2009-05-18 1:58

Code tags first.

Name: Anonymous 2009-05-18 2:00

Yesh
amidoinitrite?

Name: Anonymous 2009-05-18 2:00

        a = txtSearchWord.Text


        b = InStr(TextEditor.txtMain.Text, txtSearchWord.Text)

        If b Then

            TextEditor.txtMain.Focus()

            TextEditor.txtMain.SelectionStart = b - 1

            TextEditor.txtMain.SelectionLength = Len(a)



        Else

            MessageBox.Show("Text not found.")

Name: Anonymous 2009-05-18 2:05

>>11
Make a function that takes a position as parameter:

Private Sub Find(ByVal startPosition as integer)

That's so you can keep track of where you are in the text if you've done more than one Find (i.e. to do find next). The first time, send either 0 or 1 as the position (start). Inside the class, also declare one integer that will contain the position of your result (here, targetPosition) and one string that will actually contain the string (here, target).

Declare another position integer inside the function.
Dim position as Integer

position = InStr(startPosition, TextEditor.txtMain.Text, txtSearchWord.Text)


If to check whether or not you have a result,

If position > 0 Then
targetPosition = position


Close to what you were doing, you should get this part without explanations

TextEditor.txtMain.SelectionStart = targetPosition
TextEditor.txtMain.SelectionLength = Len(target) - (Len(target) - Len(target))


Finish the if

Else
MsgBox("Text Not Found")
target = ""
End If

Name: Anonymous 2009-05-18 2:06

>>15
Just realized I forgot to highlight. Whatever, do it yourself.

Name: Anonymous 2009-05-18 2:24

>>16
Just relized you program in Visual Basic. Get the fuck out, along with OP.

Name: Anonymous 2009-05-18 2:28

>>17
Listen here, jerkface. That's very rude and your belligerent attitude is not welcome around here.

Name: Anonymous 2009-05-18 2:29

>>17
Unlike you, my powerful brain can learn more than one language. I had to learn VB .NET as a CS freshman.

I probably know every single language you know and program better in any of them than you.

Name: Anonymous 2009-05-18 2:36

Fuck you all HTML > ALL

Name: Anonymous 2009-05-18 2:37

>>19
2/10

Name: Anonymous 2009-05-18 2:40

>>21
There was no trolling. I am an improved version of you. How does it feel to only know C?

Name: Anonymous 2009-05-18 2:46

>>All of you
How does it feel to be a faggot nerd from the internet who nobody cares about in real life. You guys are so much cooler than each other because of what code you know. Get a girlfriend and a life.

Name: Anonymous 2009-05-18 3:05

>>23
When I'm done coding Ruby, I have an active night life, and several boyfriends with whom I frequently have SEX.

Name: Anonymous 2009-05-18 3:20

>>23
That's such a trite attempt. Nobody would be stupid enough to tell others on an Internet board to get a life. I award you 0 points, and may God have mercy on your soul.

>>24
Is the sex as slow as Ruby? If so, my condolences.

Name: Anonymous 2009-05-18 5:49

>>24
several boyfriends
It's a slut!

Name: Anonymous 2009-05-18 5:54

>>26
I think the joke was that Leah codes in Ruby.

Name: Anonymous 2009-05-18 6:09

>>26
It's a faggot!
Fix'd

Name: Anonymous 2009-05-18 6:10

>>28
YOU JUST BUMPED IT!!!

Name: Anonymous 2009-05-18 6:18

>>27
My princess doesn't code in Ruby ;_; you lie

Don't change these.
Name: Email:
Entire Thread Thread List