Sign in to follow this  
Followers 0
mesale0077

The number of words in the text

10 posts in this topic

hi

The number of words in the text

but gives the number of words incorrectly

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("[#] words count [#]", 1151, 675, 126, 31)
$Edit1 = GUICtrlCreateEdit("", 32, 24, 1081, 553)
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("account", 464, 592, 137, 73)
$Button2 = GUICtrlCreateButton("Clear", 688, 592, 121, 73)
$Input1 = GUICtrlCreateInput("", 608, 608, 65, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
Case $Button1
$AD=GUICtrlRead($Edit1)
Local $line = StringSplit(($AD), ' ', 1)
GUICtrlSetData($Input1,$line[0])
Case $Button2
GUICtrlSetData($Edit1,"")
GUICtrlSetData($Input1,"")
 EndSwitch
WEnd

thank you now

Share this post


Link to post
Share on other sites



What do you mean by "incorrectly"? No number, wrong number? If it's the wrong number, "how wrong"? Means: If the correct number is 11 it shows 9?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

It seems to work for me. I ran the code, typed my first name, and $Input1 showed '1'. Then I typed in my first and last name, and $Input1 showed '2'. So, as water asked, what do you mean by 'incorrect'?


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Replace

$AD = GUICtrlRead($Edit1)
with
$AD = StringReplace(GUICtrlRead($Edit1), @CRLF, " ")
so a new line control character is treated like a word separator.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

sorry

How many words are in the text

exam

when write in editbox

eiaieaea eiaieaiue ieaieae eiaieuaie

ieaie eiaaie eiaiea

words "7 " piece

but readıng 6

dont word 6

Edited by mesale0077

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I wrote something a while back that you could look at if you want:

Edit: I think a line in one of the functions became garbled. I don't rememebr what it was either.

Edit: Fixed.

Edited by LaCastiglione

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

You had two problems in your script:

1) Line feeds didn't count as word separators

2) Multiple spaces were counted as multiple words

This should work now:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("[#] word count [#]", 1151, 675, 126, 31)
$Edit1 = GUICtrlCreateEdit("", 32, 24, 1081, 553)
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("Count", 464, 592, 137, 73)
$Button2 = GUICtrlCreateButton("Clear", 688, 592, 121, 73)
$Input1 = GUICtrlCreateInput("", 608, 608, 65, 21)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $AD = GUICtrlRead($Edit1)
            $AD = StringReplace($AD, @CRLF, " ")
            $AD = StringStripWS($AD, 7)
            Local $line = StringSplit(($AD), ' ', 1)
            GUICtrlSetData($Input1, $line[0])
        Case $Button2
            GUICtrlSetData($Edit1, "")
            GUICtrlSetData($Input1, "")
    EndSwitch
WEnd
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

thank you

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0