Sign in to follow this  
Followers 0
autosm

Set color to label variable based of number

5 posts in this topic

#1 ·  Posted (edited)

If $PingNum = 125 OR $PingNum < 125 Then
    GuiCtrlSetColor($PingNum, $COLOR_GREEN)
    
Else
    GUICtrlSetColor($PingNum, 0xff0000)
    EndIf

I have tried everything, using $COLOR_RED instead but nothing seems to work when I have $PingNum be over 125. It just doesn't want to come up as the color red when the variable is over 125.

Edited by autosm

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Wait, what is $PingNum?  You're using it as a controlid.

Edit:

BTW, if you're unsure or can't explain correctly (because your code makes little sense), then you're going to need to provide a working recreation script that demonstrates your issue.  Not a conditional statement that really says nothing.  BTW

If $PingNum <= 125 Then
is the same as your "Or" statement. Edited by SmOke_N

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.

Share this post


Link to post
Share on other sites

I ping an ip adress and the ms gets set to $PingNum.

Local $iPing = Ping("IP ADRESS THAT IS SET HERE", 1850)
If $iPing Then ; If a value greater than 0 was returned then display the following message.
GUICtrlSetData ($PingNum, $iPing)
Else
MsgBox($MB_SYSTEMMODAL, "", "An error occurred. If this conitues the region severs might be down/busy.")
EndIF
 
I have a few of those set my code based of of what radio button is selected. Everything works fine but my major issue is that when controlID PingNum is over 126 it doesnt set the color to red.

Share this post


Link to post
Share on other sites

@autosm - have a close look at the first code you posted.

You have intermixed the ID or handle of your label, with your ping variable.

This is why, it is always best to post a larger portion of code, than just some snippet.

We can see instantly then, that you have made such a glaring mistake.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

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