Jump to content

[Resolved]Check if a value is not between 2 other values


Edifice
 Share

Recommended Posts

Hello

You properly get my drift...

Func checkphonenumber()
    If GUIctrlRead($input_tlfnr, 1) > 99999999 And < 120 Then
        MsgBox(0, "Fejl", "Telefonnummeret er ikke indtastet korrekt! Venligst udfyld telefonnummeret")
        runprogram()
    EndIf
EndFunc

I wan't to exe the msgbox only if the value is not between 120 and 99999999, however it's letting me do that, and I can't really find any subjects about logical comparison - so, here I am.

Again, I really value the help I get from you guys! :)

Edited by Edifice
Link to comment
Share on other sites

Okay you're not evaluating the expression twice. You're simply doing it once, but I see what you're trying to accomplish. Lets see if the below helps you out...

Func checkphonenumber()
    If GUICtrlRead($input_tlfnr, 1) > 99999999 AND GUICtrlRead($input_tlfnr, 1) < 120 Then
        MsgBox(0, "Fejl", "Telefonnummeret er ikke indtastet korrekt! Venligst udfyld telefonnummeret")
        runprogram()
    EndIf
EndFunc

I hope that helps,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Okay you're not evaluating the expression twice. You're simply doing it once, but I see what you're trying to accomplish. Lets see if the below helps you out...

Func checkphonenumber()
    If GUICtrlRead($input_tlfnr, 1) > 99999999 AND GUICtrlRead($input_tlfnr, 1) < 120 Then
        MsgBox(0, "Fejl", "Telefonnummeret er ikke indtastet korrekt! Venligst udfyld telefonnummeret")
        runprogram()
    EndIf
EndFunc

I hope that helps,

Jarvis

Well you'd think so but now the MsgBox doesn't show at all. I guess that statement is never true - how ever that's possible?!
Link to comment
Share on other sites

Well you'd think so but now the MsgBox doesn't show at all. I guess that statement is never true - how ever that's possible?!

Well, in the first place, you don't need to set the flag for extended information on your GuiCtrlRead to 1:

GUICtrlRead($input_tlfnr, 1)

should probably be

GUICtrlRead($input_tlfnr)

In the second place, what is the format of phone numbers where you're at?

Link to comment
Share on other sites

I'm not sure what the phone number format is where you live, but I would think you could use StringRegExp to get a more precise check on whether they entered a valid phone number or not. Check it out! :)

Isn't StringRegExp just "Match or not"? - Coz I don't want to type all possible phonenumbers :S

Btw, the possible phonenumbers range from about 120 to about 99999999 - no letters, nothing fancy

Edited by Edifice
Link to comment
Share on other sites

Well, in the first place, you don't need to set the flag for extended information on your GuiCtrlRead to 1:

GUICtrlRead($input_tlfnr, 1)

should probably be

GUICtrlRead($input_tlfnr)

In the second place, what is the format of phone numbers where you're at?

Exodius,

Thanks for pointing that out for the extended data. I believe that returns an array which is amazing that it ever showed the text box before.

Judging from the text he has entered he's from Norway, and the following has a link to acceptable phone number formats. I have written a few Regular Expressions to accept phone numbers from around the world so that's why I looked this up. I cannot find my libraries at the moment or I would post the code here for the Regular Expression of Norway. I am sure a google would return it.

http://en.wikipedia.org/wiki/Telephone_numbers_in_Norway

Thanks,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Exodius,

Thanks for pointing that out for the extended data. I believe that returns an array which is amazing that it ever showed the text box before.

Judging from the text he has entered he's from Norway, and the following has a link to acceptable phone number formats. I have written a few Regular Expressions to accept phone numbers from around the world so that's why I looked this up. I cannot find my libraries at the moment or I would post the code here for the Regular Expression of Norway. I am sure a google would return it.

http://en.wikipedia.org/wiki/Telephone_numbers_in_Norway

Thanks,

Jarvis

Wowsers, that's a little different than here in the States! :) So since you have such Regular Expressions already in existence somewhere, should we wait for you to find them?

Link to comment
Share on other sites

Below is the Regular Expression I used for "International Numbers" I am not certain it includes everyone, but it certainly covers the area that I could find information on that seemed to be solid information.

$pattern = '/^(?:[+]\d{1,3}(?:[-\.\s]{1}))?(?:\(\d{1}\)(?:[-\.\s]{1}))?(?:(?:\(\d{1,6}\))|(?:\d{1,6}))(?:[-\.\s]{1})\d{2,4}(?:[-\.\s]{1})\d{4}$/';

I hope that helps if you're going to use StringRegExp(),

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

It would be kind of miracle to get msgbox out of there, ever.

You are correct! Thanks for pointing my attention to that small word AND - It's supposed to be Or

Func checkphonenumber()
    If GUICtrlRead($input_tlfnr) > 99999999 Or GUICtrlRead($input_tlfnr) < 120 Then
        MsgBox(0, "Fejl", "Telefonnummeret er ikke indtastet korrekt! Venligst udfyld telefonnummeret")
        runprogram()
    EndIf
EndFunc
Link to comment
Share on other sites

Well Actually I'm from denmark - But very nicely guessed :)

http://en.wikipedia.org/wiki/Telephone_numbers_in_Denmark

Actually, I just looked up GUICtrlRead(), and the flag for inputboxes makes no difference according to the helpfile.

Tried to change it but without luck.

I tried...are the languages similar in Denmark and Norway?

Thanks,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

You are correct! Thanks for pointing my attention to that small word AND - It's supposed to be Or

Func checkphonenumber()
    If GUICtrlRead($input_tlfnr) > 99999999 Or GUICtrlRead($input_tlfnr) < 120 Then
        MsgBox(0, "Fejl", "Telefonnummeret er ikke indtastet korrekt! Venligst udfyld telefonnummeret")
        runprogram()
    EndIf
EndFunc
Doh! :)

Can't believe I missed that myself when I re-worded the And to AND :)

Thanks,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

I tried...are the languages similar in Denmark and Norway?

Thanks,

Jarvis

Very much so - The pronouncement is a bit different but the writing are almost similar. It's properly because Denmark And Norway were one country untill not more than a couple of hundred years ago :)

Link to comment
Share on other sites

Very much so - The pronouncement is a bit different but the writing are almost similar. It's properly because Denmark And Norway were one country untill not more than a couple of hundred years ago :)

Ah okay. So it would be similar to English in different parts of the world. Pronunciations (Accents) are most different. Some have different spellings.

Glad you got it figured out. If you get brave you can try that Regular Expression...I would be pleased to know if it works for Denmark...

Thanks,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
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
 Share

  • Recently Browsing   0 members

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