Jump to content

Recommended Posts

Posted

How can i check if an input is empty?

$answer = InputBox("Question", "Where were you born?", "Planet Earth", "",  -1, -1, 0, 0)
if $answer = "" then exit
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Posted

This is what i've got

#include <GUIConstants.au3>

$Fout = "roderondje.gif"


GUICreate ( "QueueIt" , 650 , 400 ) 

$TITLE2 = GUICtrlCreateInput("", 15, 40, 100, 20)
$groen = GUICtrlCreatePic ( "roderondje.gif" , 500, 150, 20, 20)
$s_Result = 0
$q = 0
$Y = 0
GUISetState (@SW_SHOW)
While 1
    $s_Result = GUICtrlRead($TITLE2)
    $z = $Y
    $Y = StringLen($s_Result)
    
    if $z <> $Y then
    $q = 0
       For $x = 1 to StringLen($s_Result)
    $i = StringMid($s_Result,$x,1)
    $a = Asc ($i)
    
    If $s_Result = " " Then
        GUICtrlSetImage($groen,  "roderondje.gif")

    
    elseIf $a == 34 Then
        GUICtrlSetImage($groen,  "roderondje.gif")
        $q = 1
    
    elseif $a <> 34 and $q <> 1 then
        GUICtrlSetImage($groen,  "groenrondje.gif")

    endif
    next
    endif
Wend

But it doesn't work

Posted

I'm trying to create an input which checks if the input value is correct.

There are some characters than can't be written in the input. So if one of those characters is written there is picture that must turn red Posted Image

And when the text in the input doesn't have any of the forbidden characters it must be green Posted Image

But when it is empty it has to be red because it can't be empty.

Hope this makes it more clear.

Posted (edited)

#include <GUIConstants.au3>

GUICreate("QueueIt", 650, 400)

$TITLE2 = GUICtrlCreateInput("", 15, 40, 100, 20)
$StatusPic = GUICtrlCreatePic("roderondje.gif", 500, 150, 20, 20)
Dim $s_Result
GUISetState(@SW_SHOW)
While 1
    $s_Result = GUICtrlRead($TITLE2)
    If StringLen($s_Result) <> 0 Then;  $s_Result is niet leeg
        If StringInStr($s_Result, '"') Then;    Aanhalingsteken gevonden
            GUICtrlSetImage($StatusPic, "roderondje.gif")
        Else;   Geen aanhalingsteken gevonden
            GUICtrlSetImage($StatusPic, "groenrondje.gif")
        EndIf
    Else;   $s_Result is leeg
        GUICtrlSetImage($StatusPic, "roderondje.gif")
    EndIf
WEnd

Edited by Geert

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
×
×
  • Create New...