| | |
Haw to allow to enter number only from number 1 to 65535.
Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Aug 2009
Posts: 20
Reputation:
Solved Threads: 0
i have problem to allow enter only from 1 to 65535 bicouse
example if enter 10000,2000 is ok but enter 99 not.
hire 1 example (not working)
hire 2 example (not working)
please help haw to solve this.
Thanks.
example if enter 10000,2000 is ok but enter 99 not.
hire 1 example (not working)
Pascal and Delphi Syntax (Toggle Plain Text)
If somthing.Text > '65535 'then ShowMessage(' you enter biger Number from 65535'); Exit;
hire 2 example (not working)
Pascal and Delphi Syntax (Toggle Plain Text)
var result : Integer; string1: String; string2: String; begin string1:='65535'; string2:= somthing.Text; result := AnsiCompareStr(string1, string2); if result < 0 then ShowMessage(string1+' < '+string2);
please help haw to solve this.
Thanks.
•
•
Join Date: Oct 2009
Posts: 10
Reputation:
Solved Threads: 3
•
•
•
•
i have problem to allow enter only from 1 to 65535 bicouse
example if enter 10000,2000 is ok but enter 99 not.
hire 1 example (not working)
Pascal and Delphi Syntax (Toggle Plain Text)
If somthing.Text > '65535 'then ShowMessage(' you enter biger Number from 65535'); Exit;
hire 2 example (not working)
Pascal and Delphi Syntax (Toggle Plain Text)
var result : Integer; string1: String; string2: String; begin string1:='65535'; string2:= somthing.Text; result := AnsiCompareStr(string1, string2); if result < 0 then ShowMessage(string1+' < '+string2);
please help haw to solve this.
Thanks.
1. Convert your string to a number and test that.
2. create the following function and pass the string as
IF Between(Atextbox.Text,1,65535)
THEN MessageDlg('Thats OK',MtInformation,[MbOK],0)
ELSE MessageDlg('Bad Number',MtInformation,[MbOK],0);
You could also vary the Value by type and overload this to do any numbers
FUNCTION Between(Value : String;Low,High : LongInt) : BOOLEAN;
VAR
N : Integer;
Begin
TRY
N := StrtoInt(Value);
RESULT := ((N >= Low) AND (N <= High));
EXCEPT ON EConvertError DO
RESULT := FALSE;
End;
End;
•
•
Join Date: Aug 2009
Posts: 20
Reputation:
Solved Threads: 0
0
#3 Nov 3rd, 2009
•
•
•
•
[DELPHI]
1. Convert your string to a number and test that.
2. create the following function and pass the string as
IF Between(Atextbox.Text,1,65535)
THEN MessageDlg('Thats OK',MtInformation,[MbOK],0)
ELSE MessageDlg('Bad Number',MtInformation,[MbOK],0);
You could also vary the Value by type and overload this to do any numbers
FUNCTION Between(Value : String;Low,High : LongInt) : BOOLEAN;
VAR
N : Integer;
Begin
TRY
N := StrtoInt(Value);
RESULT := ((N >= Low) AND (N <= High));
EXCEPT ON EConvertError DO
RESULT := FALSE;
End;
End;
1
#4 Nov 4th, 2009
I made a pascal source code 

pascal Syntax (Toggle Plain Text)
program sablon; uses crt; type range = 1..65535; const ok = 'ok.'; error = 'error'; min = 1; var one:longint; two:range; user,temp:string; function converter(x:string):string; var code:integer; begin two:=65535; {$I-} val(x,one,code); if (ioresult <> 0) then begin converter:=error; exit; end; if (code <> 0) then begin converter:=error; exit; end; if (one > two) or (one < min) then converter:=error else converter:=ok; {$I+} end; begin clrscr; temp:=error; while temp <> ok do begin write('please enter a number from 1 to 65535: '); readln(user); temp:=converter(user); writeln(temp); end; readln; end. {created by FlamingClaw 2009}
Be a good part of the community.Don't be ungrateful.
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
![]() |
Similar Threads
- Enter Only Number In DataGridView (C#)
- Number Guessing Game (C++)
- Insert a number in an array (C++)
- ordered number (C++)
- Need help displaying when user enters negative number? (C++)
- Random Number help (Java)
- Random Number Generator (Java)
- Random number generation (C)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: Creating Simple Login Screen In DevPas
- Next Thread: runtime error as IOresult<>0
| Thread Tools | Search this Thread |
Tag cloud for Pascal and Delphi





