Private $bOK As Boolean
Public Sub Form_Open()
TextBox1.Text = "Frase di prova"
TextBox1.Pos = 0
End
Public Sub TextBox1_KeyRelease()
Dim s As String
s = TextBox1.Text
Select Key.code
Case Key.Insert
If TextBox1.Pos < Len(s) Then
If $bOK Then
$bOK = False
Else
TextBox1.Select(TextBox1.Pos, 1)
$bOK = True
Endif
Endif
Case Key.Space
If $bOK Then
If TextBox1.Pos < Len(s) Then
TextBox1.Select(TextBox1.Pos, 1)
Else
$bOK = False
Endif
Endif
End Select
Select Case Key.Text
Case "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"
If $bOK Then
If TextBox1.Pos < Len(s) Then
TextBox1.Select(TextBox1.Pos, 1)
Else
$bOK = False
Endif
Endif
Case "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
If $bOK Then
If TextBox1.Pos < Len(s) Then
TextBox1.Select(TextBox1.Pos, 1)
Else
$bOK = False
Endif
Endif
Case "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
If $bOK Then
If TextBox1.Pos < Len(s) Then
TextBox1.Select(TextBox1.Pos, 1)
Else
$bOK = False
Endif
Endif
Case "\\", "|", "\"", "!", "£", "$", "%", "&", "/", "(", ")", "=", "?", "ì", "^", "{", "}", "~", "\'"
If $bOK Then
If TextBox1.Pos < Len(s) Then
TextBox1.Select(TextBox1.Pos, 1)
Else
$bOK = False
Endif
Endif
Case "è", "é", "+", "*", "ò", "à", "ù", "°", "[", "]", "#", "@", "ç", "<", ">", "§", "€"
If $bOK Then
If TextBox1.Pos < Len(s) Then
TextBox1.Select(TextBox1.Pos, 1)
Else
$bOK = False
Endif
Endif
End Select
End
...... e poi... ci mancavi tu :P
Private bb As Byte[]
Private i As Integer
Public Sub Form_Open()
TextBox1.Text = "prova"
bb = Byte[].FromString(TextBox1.Text)
TextBox1.Pos = 0
End
Public Sub TextBox1_KeyPress()
If i = bb.Count Then bb.Push(32)
bb[i] = Asc(Key.Text)
Inc i
TextBox1.Text = bb.ToString(0, bb.Count)
TextBox1.Pos = i
Stop Event
End
TextBox1.Select(TextBox1.Pos, 1)
Else
$bOK = True
Case Key.Insert
Propongo questo codice:
...
Private $sFrase As String
Private $bOK As Boolean
Public Sub Form_Open()
TextBox1.Text = "Frase di prova"
TextBox1.Pos = 0
End
Public Sub TextBox1_KeyRelease()
Dim s As String
$sFrase = TextBox1.Text
Select Key.code
Case Key.Insert
If TextBox1.Pos < Len($sFrase) Then
If $bOK Then
$bOK = False
Else
TextBox1.Select(TextBox1.Pos, 1)
$bOK = True
Endif
Endif
Case Key.Space
mySel()
End Select
Select Case Key.Text
Case "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"
mySel()
Case "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
mySel()
Case "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
mySel()
Case "\\", "|", "\"", "!", "£", "$", "%", "&", "/", "(", ")", "=", "?", "ì", "^", "{", "}", "~", "\'"
mySel()
Case "è", "é", "+", "*", "ò", "à", "ù", "°", "[", "]", "#", "@", "ç", "<", ">", "§", "€"
mySel()
End Select
End
Private Sub mySel()
If $bOK Then
If TextBox1.Pos < Len($sFrase) Then
TextBox1.Select(TextBox1.Pos, 1)
Else
$bOK = False
Endif
Endif
End
Qui direi che "soluzioni non convenzionali" ci può stare...non direi che l'uso di un vettore di tipo Byte[ ] sia una soluzione non convenzionale.
Qui direi che "soluzioni non convenzionali" ci può stare...non direi che l'uso di un vettore di tipo Byte[ ] sia una soluzione non convenzionale.
era per scherzareL'avevo capito, ma gli eventuali principianti potrebbero interpretare in modo errato la frase, pensando che l'uso di una variabile vettoriale di tipo non strettamente corrispondente al tipo String, come lo è appunto il vettore di tipo Byte[ ], non sia opportuno e mai conveniente nella gestione di una stringa di caratteri.....che poi non sono altro che valori da 8 bit ciascuno. :D
Ho dovuto reinstallare completamente Ubuntu e ho fatto notte e poi... ci mancavi tu :P:evil:
:evil:...... e poi... ci mancavi tu :P
:rotfl:
Gianluigi
per quanto riguardo il tuo suggerimento non sortisce nessun effetto, e come che non ci sia. L'ho provato più volte
ma niente
' Gambas class file
Private $bOK As Boolean ' Se Inserimento è attivo o no
Public Sub Form_Open()
' Inserisce la frase e ne porta il cursore all'inizio.
TextBox1.Text = "Frase di prova"
TextBox1.Pos = 0
End
Public Sub TextBox1_KeyRelease()
' Controlla che sia attivo l'inserimento e se ci sono caratteri da sostituire lo fa.
Dim s As String, i As Integer
s = TextBox1.Text
Select Key.code
Case Key.Insert, Key.Ins
If $bOK Then
$bOK = False
TextBox1.Unselect()
Else
TextBox1.Select(TextBox1.Pos, 1)
$bOK = True
Endif
Case Key.Left, Key.BackSpace
i = TextBox1.Pos - 1
TextBox1.Select(i, 1)
Case Else
TextBox1.Select(TextBox1.Pos, 1)
End Select
End
Public Sub Form_Open()
TextBox1.Text = "prova"
TextBox1.Pos = 0
End
Public Sub TextBox1_KeyPress()
If Key.Code < 220 Then TextBox1.Select(TextBox1.pos, 1)
End
Changeons les dames !
Public Sub TextBox1_KeyPress()
If (Key.Code > 47) And (Key.Code < 58) Then TextBox1.Select(TextBox1.pos, 1)
If ((Key.Code > 47) And (Key.Code < 58)) Or Key.Code > 220 Then
Return
Else
Stop Event
Endif
End
Public Sub Form_Open()
TextBox1.Alignment = 2
TextBox2.Alignment = 2
End
...se tu avessi letto con un Print il comando Key.Code......Codice: [Seleziona]Public Sub TextBox1_KeyPress()
If (Key.Code > 47) And (Key.Code < 58) Then TextBox1.Select(TextBox1.pos, 1)
If ((Key.Code > 47) And (Key.Code < 58)) Or Key.Code > 220 Then
Return
Else
Stop Event
Endif
End
@ Gianluigi
Non hai letto con attenzione ciò che ho chiesto.... :nono:
Grazie comunque per la risposta
Public Sub TextBox1_MouseUp()
TextBox1.Alignment = 1 ' ***** Codice suggerito da Vuott
' TextBox1.SelectAll() ' Metodo 1
' TextBox1.Select(0, Len(TextBox1.Text)) ' Metodo 2
End
' Gambas class file
Public Sub Form_Open()
TextBox1.Alignment = 2
TextBox2.Alignment = 2
End
Public Sub TextBox1_KeyPress()
If (Key.Code > 47) And (Key.Code < 58) Then TextBox1.Select(TextBox1.pos, 1)
If ((Key.Code > 47) And (Key.Code < 58)) Or Key.Code > 220 Then
Return
Else
Stop Event
Endif
End
Public Sub TextBox1_Activate()
TextBox2.Text = TextBox1.Text
End
...ma....... non mi pare che questa parte di codice sia mia ! :rolleyes:Codice: [Seleziona]TextBox1.Alignment = 1 ' ***** Codice suggerito da Vuott
' TextBox1.SelectAll() ' Metodo 1
' TextBox1.Select(0, Len(TextBox1.Text)) ' Metodo 2
End