Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Foreign Languages > German Forum
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

nur bestimmte Zeichen in einer Textbox

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-17-2009, 06:42 PM
Junior Member
 
Join Date: Dec 2009
Posts: 22
Default nur bestimmte Zeichen in einer Textbox

Hallo, ich bins mal wieder !

Ich möchte in einer Textbox nur bestimmte Zeichen zulassen (0,1,2,3,4,5,6,7,8,9,.)

Habe dass versucht mit dem Keypress event und dann:
Code:
If key = Chr(46Then 
        
Else      
            TextBox3.IgnoreKey
            
End If
Leider bekomme ich es nur hin dass ich nur ein Zeichen (und kein anderes) eingeben kann.



Gruß
mezzomix
Reply With Quote
  #2 (permalink)  
Old 12-17-2009, 07:06 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 3,827
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Eine Lösung unter Anderen ist diese:
Code:
<font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Sub </font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">TextBox3_KeyPress (key)</font></font>
</font></font><font face=
"Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"If</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2"> key<></font></font></font></font><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000">"0"</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">AND</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2"> key<></font></font></font></font><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000">"1"</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">AND</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2"> key<></font></font></font></font><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000">"2"</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Then</font></font></font>
</font></font></font></font></font></font><font face=
"Courier New"><font size="2"><font face="Courier New"><font size="2">   TextBox3.IgnoreKey</font></font>
</font></font><font face=
"Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"End</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">If</font></font></font>
<font size=
"2"><font face="Courier New"><font color="#0000ff">End Sub</font></font></font></font></font></font></font></font></font>
Beste Grüsse.
__________________
Klaus
Switzerland
Reply With Quote
  #3 (permalink)  
Old 12-17-2009, 07:17 PM
Junior Member
 
Join Date: Dec 2009
Posts: 22
Default

Danke schonmal!
Jetzt ist mir noch aufgefallen dass ich ja garkein backspace drücken kann. habe dass versucht so dranzuhängen - AND key <> 8 - aber das geht so nicht

Gruss
mezzomix

Last edited by mezzomix : 12-17-2009 at 07:33 PM.
Reply With Quote
  #4 (permalink)  
Old 12-17-2009, 08:17 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 3,827
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hier musst Du es so schreiben:
Code:
<font color="#0000ff">Sub </font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">TextBox3_KeyPress (key)</font></font>
</font></font><font face=
"Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">If</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2"> key<></font></font></font></font><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000">"0" </font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">AND</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2"> key<></font></font></font></font><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000">"1" </font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">AND</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2"> key<></font></font></font></font><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000">"2" <font color="#0000ff">AND</font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2"><font color="#000000"> key<>Chr(8) </font></font></font></font></font></font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Then</font></font></font>
</font></font></font></font></font></font><font face=
"Courier New"><font size="2"><font face="Courier New"><font size="2">TextBox3.IgnoreKey</font></font>
</font></font><font face=
"Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">End </font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">If</font></font></font>
<font size=
"2"><font face="Courier New"><font color="#0000ff">End Sub</font></font></font></font></font></font></font></font></font>
Beste Grüsse.
__________________
Klaus
Switzerland
Reply With Quote
  #5 (permalink)  
Old 12-17-2009, 10:32 PM
Junior Member
 
Join Date: Dec 2009
Posts: 22
Default

Dank Dir!!
Reply With Quote
  #6 (permalink)  
Old 12-17-2009, 10:33 PM
Filippo's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Schwäb. Gmünd, Germany
Posts: 906
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hallo mezzomix,

hier noch eine Variante:
Code:
Sub TextBox1_KeyPress (key)
    
If StrIndexOf ("0123456789." & Chr(8) , key,0) = -1 Then
        TextBox1.IgnoreKey
    
End If
End Sub
oder noch besser mit hilfe von http://www.basic4ppc.com/forum/addit...s-library.html.
Schau dir einfach die Beispiele an.


Ciao,
Filippo
__________________
PPC: MDA Pro, 2GB SD
Device: HTC Desire , Android 2.2
______________________
Reply With Quote
  #7 (permalink)  
Old 12-18-2009, 12:26 AM
Junior Member
 
Join Date: Dec 2009
Posts: 22
Default

Ich komme nicht mal auf eine Methode und dann gibt es gleich mehrere

Danke euch!

gruß mezzomix
Reply With Quote
  #8 (permalink)  
Old 12-19-2009, 08:55 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 3,827
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hallo Filippo,

Deine Variante gefällt mir !
Kürzerer, übersichtlicher und wahrscheinlich auch schnellerer Code.

Beste Grüsse.
__________________
Klaus
Switzerland
Reply With Quote
  #9 (permalink)  
Old 12-22-2009, 07:46 PM
Filippo's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Schwäb. Gmünd, Germany
Posts: 906
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hallo Klaus,

ich verwende diese Variante in meine Library "fgControls" schon lange.

Bei diese gelegenheit wünsche dir und deine Familie Fröhliche Weihnachten.


Filippo
__________________
PPC: MDA Pro, 2GB SD
Device: HTC Desire , Android 2.2
______________________
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Zuerst eine Tabelle filtern und dann in eine bestimmte Spalte einen Wert setzen JOTHA German Forum 20 10-07-2009 05:17 PM
Problem mit einer CSV-Tabelle JOTHA German Forum 12 09-21-2009 01:26 PM
Auslesen einer Tabelle in eine Textbox und löschen von "0,00-Ergebnissen" JOTHA German Forum 8 11-29-2008 09:50 AM
Elektroschaltplan zeichen Bobbes German Forum 202 11-11-2008 09:14 PM
max. Anzahl der Zeichen einer textbox.... Bobbes German Forum 3 03-01-2008 04:24 PM


All times are GMT. The time now is 03:25 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0