Ich hab mal ein paar Funktionen für Textfelder gebaut:
BlitzBasic: [AUSKLAPPEN] [EINKLAPPEN] Function TextFieldLength(tf_id,length) Local ftext$ = TextFieldText$(tf_id) If Len(ftext$) > length Then ftext$ = Left(ftext$,length) SetGadgetText(tf_id,ftext$) Return 1 EndIf End Function Function TextFieldNumberArea(tf_id,zahl1,zahl2)
Local tmp Local change = 0 If zahl1 > zahl2 Then tmp = zahl1 zah1 = zahl2 zahl2 = tmp EndIf zahl = Int(TextFieldText$(tf_id)) If zahl < zahl1 Then zahl = zahl1 change = 1 EndIf If zahl > zahl2 Then zahl = zahl2 change = 1 EndIf If change Then SetGadgetText(tf_id,Str$(zahl)) Return 1 EndIf End Function BlitzBasic: [AUSKLAPPEN] [EINKLAPPEN]
Function TextFieldReplace(tf_id,mode=0,a_txt$=\"\") If (mode < 0) Or (mode > 5) Then Return 0 Local change = 0 Local ascii = 0 Local ftext$ = TextFieldText$(tf_id) Local i Local j Local ftextmid$ Local repl$ Local in Select mode Case 0 For ascii = 0 To 44 If Instr(ftext$,Chr$(ascii)) Then change = 1 ftext$ = Replace$(ftext$,Chr$(ascii),\"\") EndIf Next For ascii = 46 To 47 If Instr(ftext$,Chr$(ascii)) Then change = 1 ftext$ = Replace$(ftext$,Chr$(ascii),\"\") EndIf Next For ascii = 58 To 255 If Instr(ftext$,Chr$(ascii)) Then change = 1 ftext$ = Replace$(ftext$,Chr$(ascii),\"\") EndIf Next If Len(ftext$) > 1 Then ftext2$ = Right(ftext$,Len(ftext$)-1) If Instr(ftext2$,\"-\") Then ftext2$ = Replace(ftext2$,\"-\",\"\") ftext$ = Left(ftext$,1)+ftext2$ change = 1 EndIf EndIf Case 1 For ascii = 0 To 64 If Instr(ftext$,Chr$(ascii)) Then change = 1 ftext$ = Replace$(ftext$,Chr$(ascii),\"\") EndIf Next For ascii = 91 To 96 If Instr(ftext$,Chr$(ascii)) Then change = 1 ftext$ = Replace$(ftext$,Chr$(ascii),\"\") EndIf Next For ascii = 123 To 255 If Instr(ftext$,Chr$(ascii)) Then change = 1 ftext$ = Replace$(ftext$,Chr$(ascii),\"\") EndIf Next Case 2 For ascii = 0 To 47 If Instr(ftext$,Chr$(ascii)) Then change = 1 ftext$ = Replace$(ftext$,Chr$(ascii),\"\") EndIf Next For ascii = 58 To 64 If Instr(ftext$,Chr$(ascii)) Then change = 1 ftext$ = Replace$(ftext$,Chr$(ascii),\"\") EndIf Next For ascii = 91 To 96 If Instr(ftext$,Chr$(ascii)) Then change = 1 ftext$ = Replace$(ftext$,Chr$(ascii),\"\") EndIf Next For ascii = 123 To 255 If Instr(ftext$,Chr$(ascii)) Then change = 1 ftext$ = Replace$(ftext$,Chr$(ascii),\"\") EndIf Next If Instr(ftext$,\"-\") And Left(ftext$,1) <> \"-\" Then ftext$ = Replace(ftext$,\"-\",\"\") change = 1 EndIf Case 3 If Instr(ftext$,\"\\") Then ftext$ = Replace$(ftext$,\"\\",\"\") change = 1 EndIf If Instr(ftext$,\"/\") Then ftext$ = Replace$(ftext$,\"/\",\"\") change = 1 EndIf If Instr(ftext$,\":\") Then ftext$ = Replace$(ftext$,\":\",\"\") change = 1 EndIf If Instr(ftext$,\"*\") Then ftext$ = Replace$(ftext$,\"*\",\"\") change = 1 EndIf If Instr(ftext$,\"?\") Then ftext$ = Replace$(ftext$,\"?\",\"\") change = 1 EndIf If Instr(ftext$,Chr(34)) Then ftext$ = Replace$(ftext$,Chr(34),\"\") change = 1 EndIf If Instr(ftext$,\"<\") Then ftext$ = Replace$(ftext$,\"<\",\"\") change = 1 EndIf If Instr(ftext$,\">\") Then ftext$ = Replace$(ftext$,\">\",\"\") change = 1 EndIf If Instr(ftext$,\"|\") Then ftext$ = Replace$(ftext$,\"|\",\"\") change = 1 EndIf Case 4 For i = 1 To Len(a_txt$) repl$ = Mid$(a_txt$,i,1) If Instr(ftext$,repl$) Then ftext$ = Replace(ftext$,repl$,\"\") change = 1 EndIf Next Case 5 For i = 1 To Len(ftext$) ftextmid$ = Mid$(ftext$,i,1) in = 0 For j = 1 To Len(a_txt$) repl$ = Mid(a_txt$,j,1) If ftextmid$ = repl$ Then in = 1 Next If in = 0 Then ftext$ = Replace(ftext$,ftextmid$,\"\") change = 1 EndIf Next End Select If change Then SetGadgetText(tf_id,ftext$) Return 1 End Function
|