48 lines
2.1 KiB
Plaintext
48 lines
2.1 KiB
Plaintext
Module CheckIt {
|
|
Declare form1 form
|
|
Declare textbox1 textbox form form1
|
|
Declare buttonInc Button form form1
|
|
Declare buttonRND Button form form1
|
|
Method textbox1, "move", 2000,2000,4000,600
|
|
Method buttonInc, "move", 2000,3000,2000,600
|
|
Method buttonRND, "move", 4000,3000,2000,600
|
|
With form1, "Title", "Rosetta Code: GUI component interaction"
|
|
With textbox1,"vartext" as textbox1.value$, "Prompt", "Value:", "ShowAlways", true
|
|
With buttonInc,"Caption","Increment"
|
|
With buttonRND,"Caption","Random"
|
|
textbox1.value$="0"
|
|
Function Local1(new Feed$) {
|
|
\\ this Function can be used from other Integer
|
|
\\ this$ and thispos, exist just before the call of this Function
|
|
local sgn$
|
|
if feed$="" and this$="-" then thispos-- : exit
|
|
if left$(this$,1)="-" then sgn$="-": this$=mid$(this$, 2)
|
|
if this$<>Trim$(this$) then this$=Feed$ : thispos-- : exit
|
|
If Trim$(this$)="" then this$="0" : thispos=2 : exit
|
|
if instr(this$,"+")>0 and sgn$="-" then this$=filter$(this$, "+") : sgn$=""
|
|
if instr(this$,"-")>0 and sgn$="" then this$=filter$(this$, "-") : sgn$="-"
|
|
if filter$(this$,"0123456789")<>"" then this$=Feed$ : thispos-- : exit
|
|
if len(this$)>1 then While left$(this$,1)="0" {this$=mid$(this$, 2)}
|
|
this$=sgn$+this$
|
|
if this$="-0" then this$="-" : thispos=2
|
|
}
|
|
Function TextBox1.ValidString {
|
|
\\ this Function called direct from textbox
|
|
Read New &this$, &thispos
|
|
Call Local local1(textbox1.value$)
|
|
}
|
|
Function buttonInc.Click {
|
|
textbox1.value$=str$(val(textbox1.value$)+1, "")
|
|
}
|
|
Function buttonRND.Click {
|
|
If AsK$("Change Value with random number", "Question", "Yes", "No")="Yes" Then {
|
|
textbox1.value$=str$(Random(0, 10000), "")
|
|
After 100 {Try {Method textbox1,"GetFocus"}}
|
|
}
|
|
}
|
|
\\ open modal
|
|
Method form1, "show", 1
|
|
Declare form1 nothing
|
|
}
|
|
Checkit
|