Hi! Need to count long words in LIX (1 Viewer)

FreshCoder

Registered User.
Local time
Today, 10:19
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

  • Tekstanalyse2.accdb
    552 KB · Views: 37

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:19
Joined
May 7, 2009
Messages
19,169
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
 

FreshCoder

Registered User.
Local time
Today, 10:19
Joined
Sep 22, 2018
Messages
33
im getting error on the first line :
public fnWordCount(sString As String, Optional iMaxLen As Integer = 6) As Integer
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:19
Joined
Sep 21, 2011
Messages
14,044
Need function in there
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:19
Joined
Sep 21, 2011
Messages
14,044
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
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:19
Joined
May 7, 2009
Messages
19,169
here.
study the code that I made for you.
run the form, select the files and click the button.
 

Attachments

  • Tekstanalyse2.zip
    37.7 KB · Views: 44

FreshCoder

Registered User.
Local time
Today, 10:19
Joined
Sep 22, 2018
Messages
33
Im a bit newbiee here :(
Can you help me why i get errors? plz
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:19
Joined
May 7, 2009
Messages
19,169
what error do you get and which line?
 

James Dickinson

PigeonPie
Local time
Tomorrow, 06:19
Joined
May 10, 2018
Messages
43
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

Top Bottom