Access a Friend function in a Class module from a standard Moldule

milovnik

New Member
Joined
Mar 10, 2014
Messages
3
Hello.
I´m trying to make my procedure faster, which starts with reading a few MB txt file line by line and by checking for the presence of a string in each line.
For testing I downloaded this code, which is ought to make the InStr search much faster: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=30761&lngWId=1

A new Class Module was created upon import of the code. The code contains the following function:
Friend Function InString(Start As Long, String1 As String, String2 As String, Optional Compare As VbCompareMethod = vbBinaryCompare) As Long

How can I use this InString function from my standard module? I never used or heard of Class Modules before.

Thanks for any help.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You need to create an instance of the class and call its method. For example:

Code:
    Dim c As InString
    Set c = New InString
    MsgBox c.InString(1, "hello", "e")
 
Upvote 0
Thanks RoryA. It did work. I've googled the issue before and saw this solution, but didn't get the explanation there.
For those who are interested, my procedure got faster by ca. 20% using the new InString function. The slowest part is apparently reading of the txt file.
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,539
Members
449,038
Latest member
Guest1337

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top