Oppure

Loading
17/11/07 20:39
Due
Come posso fare a fare in modo che in una textbox sia possibile immetere solo certi caratteri? avevo trovato un programma simile nell'area download ma non riesco più a trovarlo :D
aaa
17/11/07 21:47
LuigiBiasi
dovresti agire nell'evento Change della textbox e prendere l'ultimo valore e verificarlo. Per esempio:
'evento change della textbox
dim c as string
c = right(text1.text,1)
select case c
 case "a"
  text1.text = left(text1.text,len(text1.text)-1)
 case "e"
  text1.text = left(text1.text,len(text1.text)-1)
 case "i"
  text1.text = left(text1.text,len(text1.text)-1)
 case "o"
  text1.text = left(text1.text,len(text1.text)-1)
 case "u"
  text1.text = left(text1.text,len(text1.text)-1)
end select

questo esempio non permette di scrivere le vocali.
Ciao.
aaa
18/11/07 6:04
gius
Questo accetta solo caratteri numerici
in un modulo bas

Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long

Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const GWL_STYLE = (-16)
Public Const ES_NUMBER = &H2000&
Public Sub SetNumber(Text1 As TextBox, Flag As Boolean)
Dim curstyle As Long
Dim newstyle As Long

curstyle = GetWindowLong(Text1.hwnd, GWL_STYLE)

If Flag Then
curstyle = curstyle Or ES_NUMBER
Else
curstyle = curstyle And (Not ES_NUMBER)
End If

newstyle = SetWindowLong(Text1.hwnd, GWL_STYLE, curstyle)
Text1.Refresh
End Sub


La sintassi da inserire nel Form.Load é questa
SetWindowLong(Text1.hwnd, GWL_STYLE, curstyle)

__________________________________________________
La programmazione non é una cosa che piace a tutti :D
aaa
18/11/07 13:33
antometal
credo che sia il mio il programma a cui ti riferisci

pierotofy.it/pages/sorgenti/Visual_Basic_p2/

il programma si chiama: Solo caratteri selezionati
aaa
19/11/07 13:39
gius
antometal non per offenderti ma questo codice l'ho fatto io senza "sbirciare" da altri prog:ot::ot::-|
aaa
19/11/07 15:24
antometal
nn mi offendo...

ti assicuro xò che questo codice l' ho scritto da me in vista di un compito scolastico, ed è sicuramente possibile che sia simile al tuo (che sinceramente nn ho mai visto) o al codice di altri programmatori in quanto sia un codice semplice, breve e credo sia l' unico modo per realizzare quel programma
aaa
20/11/07 6:33
gius
FORSE SIMILE!!!!!:D:D
aaa