Jump to content

Recommended Posts

Posted (edited)

Somthing like that:

Dim $Count = 0

GUICreate("Count Words GUI", 300, 200)
$IdControl = GUICtrlCreateEdit("my words count", 50, 10)
$Button1 = GUICtrlCreateButton("Count", 120, 170, 60)

GUISetState()

While 1
    $Msg = GUIGetMsg()
    Select
        Case $Msg = -3
            Exit
        Case $Msg = $Button1
            $ReadCtrl = StringStripWS(StringReplace(GUICtrlRead($IdControl), @CRLF, " "), 3)
            $ReadCtrlArr = StringSplit($ReadCtrl, " ")
            If IsArray($ReadCtrlArr) And $ReadCtrl <> "" Then $Count = $ReadCtrlArr[0]
            If $Count <> 0 Then
                $WordsMsg = "word"
                If $Count > 1 Then $WordsMsg = "words"
                MsgBox(64, "", "There is <" & $Count & "> " & $WordsMsg & " in the edit Ctrl")
                $Count = 0
            Else
                MsgBox(48, "Error", "There is no words in the Edit Ctrl")
            EndIf
    EndSelect
WEnd
Edited by MsCreatoR

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • Moderators
Posted

#include <array.au3>
$sString = "How could i count the words."
$aArray = StringRegExp($sString, "[\s\.:;,]*([a-zA-Z0-9-_]+)[\s\.:;,]*", 3)
MsgBox(0, 'Word Count', UBound($aArray))
_ArrayDisplay($aArray, '')

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

Wow! All of your scripts work perfectly thanks alot. I think i'll have to SmokeNs (I'll reference this time:D) because it's easy to read and works the best. Thanks all.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...