Sign in to follow this  
Followers 0
madmorgan

edit box max length

6 posts in this topic

Hello All,

i want to have a edit box that a user can input text but i also want to to show him how much text space he has left.

so the edit box will have a max text lenght of 1000 but i want the count down to show on the screen as well.

hop you lot know what i want some knows how to do it please help thanks for your time.

Share this post


Link to post
Share on other sites



Hello All,

i want to have a edit box that a user can input text but i also want to to show him how much text space he has left.

so the edit box will have a max text lenght of 1000 but i want the count down to show on the screen as well.

hop you lot know what i want some knows how to do it please help thanks for your time.

Well, I spent about a minute in the help file and found GUICtrlSetLimit() and StringLen()

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Share this post


Link to post
Share on other sites

how can i output the remaining length thats left

Share this post


Link to post
Share on other sites

ok i have a go with those two functions i gan get the maths to work but i want the maths to show on screen but also i want to keep counting down as exted is enterd or up when text is removed. here is what i got.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$math = 0

#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Form1", 626, 444, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 72, 24, 385, 361)
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("Button1", 520, 168, 75, 25)
$Label1 = GUICtrlCreateLabel("Text Space Left", 520, 248, 36, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $Button1
            $read = GUICtrlRead($Edit1)
            $max = 1000
            $len = StringLen($read)
            ;maths
            $maths = $max - $len
            MsgBox(0,"",$maths)
            GUICtrlSetData($Label1, $maths, 1)



    EndSwitch
WEnd

i cant get it to output the information and i want to keep updating when new text is enteded or removed.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$math = 0
Global $btn = "shown", $temp =""
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Form1", 626, 444, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 72, 24, 385, 361)
GUICtrlSetLimit(-1, 1000)
GUICtrlSetData(-1, "")
$Button2 = GUICtrlCreateButton("Button1", 520, 168, 75, 25)
$Label1 = GUICtrlCreateLabel("1000", 520, 248, 36, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $Button2
            $read = GUICtrlRead($Edit1)
            $max = 1000
            $len = StringLen($read)
            ;maths
            $maths = $max - $len
            MsgBox(0,"",$maths)
            GUICtrlSetData($Label1, $maths, 1)
        EndSwitch

        $entered = GUICtrlRead($Edit1)
        If $entered <> "" And GUICtrlRead($Edit1)<> $temp Then
            $temp = GUICtrlRead($Edit1)
            GUICtrlSetData($Label1, 1000- StringLen($temp))
            EndIf

if $entered <> "" And $btn <> "shown" Then
    GUICtrlSetState($Button2, $GUI_ENABLE)
    $btn = "shown"
ElseIf $entered = "" And $btn <> "hidden" Then
    GUICtrlSetState($Button2, $GUI_DISABLE)
    GUICtrlSetData($Label1, "1000")
    $btn = "hidden"
EndIf



WEnd

Edited by Godless

_____________________________________________________________________________

Share this post


Link to post
Share on other sites

wow that works better than i thought it would thanks

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