We help IT Professionals succeed at work.
Get Started

VB6 - Search and replace function

Wilder1626
Wilder1626 asked
on
132 Views
Last Modified: 2016-02-17
Hi

I have a form with 3 MSHFlexgrid. Each grid are populated.

On the side, i have  2 combobox, one to select what MSHFlexgrid i want to search in, the second if the header column name.

Then, i have the Search value I want to search for and then, the replace Textbox with what i want to replace the value with.

So far, i was using this below code, but this is only for hard coded MSHFlexgrid and column.

I can i update it to adjust based on the the 2 combobox

search value
Private Sub replace_value_Click()
    Dim i As Long
    Dim LastRow As Long
    Dim Found As Boolean

    If Len(Trim(search.Text)) = 0 Then Exit Sub

    For i = 1 To MSHFlexGrid1.Rows - 1
        If search.Text = Mid(MSHFlexGrid1.TextMatrix(i, 2), 1, Len(Trim(search.Text))) Then
            LastRow = i
            Found = True

            If Found = True Then
                MSHFlexGrid1.TextMatrix(i, 2) = replace.Text
                Exit Sub
            Else

            End If
        End If

    Next
End Sub

Open in new window

VB6-search.zip
Comment
Watch Question
Social distance - Wear a mask - Don't touch your face - Wash your hands for 20 seconds
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
This problem has been solved!
Unlock 1 Answer and 13 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE