Hi! Need to count long words in LIX

FreshCoder

Registered User.
Local time
Today, 14:38
Joined
Sep 22, 2018
Messages
33
Hi!


Im doing LIX now. And need to count words longer than 6 letters.
Can anyone help me?
Is there something with instr i dont understand?


Code:
Hi!


Im doing LIX now. And need to count words longer than 6 letters.
Can anyone help me?
Is there something with instr i dont understand?


Im sorry its in english. I hope you can help me figure this formula for words longer than 6. :)
 

Attachments

you need to break the sentences into words using Split():

public fnWordCount(sString As String, Optional iMaxLen As Integer = 6) As Integer
Dim v As Variant
Dim i As Integer
sString = Trim(sString & "")
While Instr(sString, " ")
sString = Replace(sString, " ", " ")
Wend
If Len(sString) >iMaxLen Then
v = Split(sString, " ")
For i = 0 To Ubound(v)
if Trim(v(I))>iMaxLen Then fnWordCount = fnWordCount + 1
Next I
End If
End Function
 
im getting error on the first line :
public fnWordCount(sString As String, Optional iMaxLen As Integer = 6) As Integer
 
Need function in there
 
Public Function fnWordCount ?

You really have to start trying to understand what you are using.?:banghead:
You cannot expect people to create everything for you, though Arne is very good at writing code for people. However everyone can make mistakes.

I'm more of a 'Teach a man to fish' person, as that is how I learn.

So try an understand what you have been given.

Arne missed the keyword Function from the first line.
We know it should be Function as he ends the code with End Function and his naming convention is to prefix function names with fn.

HTH
 
here.
study the code that I made for you.
run the form, select the files and click the button.
 

Attachments

Im a bit newbiee here :(
Can you help me why i get errors? plz
 
what error do you get and which line?
 
just missing the word "function"

public function fnWordCount(sString As String, Optional iMaxLen As Integer = 6) As Integer

excellent little loop arnelgp , I was thinking of just replacing spaces with commas and then entering each into an array and then loop the array.
But I like yours better.

Another way could be to pass each word into a table and dcount where len of word >= 6
 

Users who are viewing this thread

Back
Top Bottom