Visual Basic - ¿pasar al siguiente textbox vb6?

Life is soft - evento anual de software empresarial
 
Vista:

¿pasar al siguiente textbox vb6?

Publicado por sebastian (1 intervención) el 12/02/2013 17:03:01
tengo una aplicacion con 4 textbox con la propiedad maxlength a 80
lo que quiero es que al escribir en el primer textbox se pase automaticamente al segundo y despues al tercero si no he apretado espacio y la palabra es grande y va a llegar al limite de caracteres pase al siguinete textbox la palabra incompleta para poder continuar en el otro textbox sera algo asi

| hola como estan esp|
|ero que bien |

yo quiero que pase esto
| hola como estan |
|espero que bien
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de A.H.H

¿pasar al siguiente textbox vb6?

Publicado por A.H.H (116 intervenciones) el 16/02/2013 00:12:10
Hola te he hecho un ejemplo con 4 textbox y la propiedad maxlenght en 30, en el cuarto textbox en change no hay que poner nada puesto que despues ya no siguen mas textbox.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Option Explicit
 
 
Private Sub Form_Load()
Text1.MaxLength = 30
Text2.MaxLength = 30
Text3.MaxLength = 30
Text4.MaxLength = 30
End Sub
 
Private Sub Text1_Change()
If Len(Text1.Text) = Text1.MaxLength Then
tratar Text1, Text2
End If
End Sub
 
 
Sub tratar(textboxatratar As textbox, textboxposterior As textbox)
Dim linea, remplazar, cortar As String
Dim separar As Variant
Dim n As Integer
Dim largo As Long
'la linea que escribimos en el textbox'
 
linea = textboxatratar.Text
separar = Split(linea, " ")
'separamos las palabras de la linea por los espacios'
'obtenemos la ultima palabra de la linea'
For n = 0 To UBound(separar)
cortar = separar(n)
Next
 
'obtenemos la posicion donde esta la palabra a suprimir'
largo = InStrRev(linea, cortar, , vbTextCompare) - 1
remplazar = Left$(linea, largo)
'suprimimos la palabra de la linea de texto'
textboxatratar = remplazar
'siguiente textbox'
textboxposterior.SetFocus
'ponemos la palabra'
textboxposterior.Text = cortar
'posicionamos el cursor despues de la palabra para seguir escribiendo'
textboxposterior.SelStart = Len(textboxposterior.Text)
End Sub
 
Private Sub Text2_Change()
If Len(Text2.Text) = 30 Then
tratar Text2, Text3
End If
End Sub
 
Private Sub Text3_Change()
If Len(Text3.Text) = 30 Then
tratar Text3, Text4
End If
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

¿pasar al siguiente textbox vb6?

Publicado por Javier (1 intervención) el 20/03/2013 02:06:12
Hola, yo te entendi que cuando escribes 80 caracteres, automaticamente se pasa el foco al segundo para tener otros ochenta caracteres, y asi sucesibamente

Private Sub Form_Load()
Text1.MaxLength = 80
Text2.MaxLength = 80
Text3.MaxLength = 80
Text4.MaxLength = 80
End Sub

Private Sub Text1_Change()
If Len(Text1.Text) = Text1.MaxLength Then
Text2.SetFocus
End If
End Sub


Private Sub Text2_Change()
If Len(Text2.Text) = Text2.MaxLength Then
Text3.SetFocus
End If
End Sub

Private Sub Text3_Change()
If Len(Text3.Text) = Text3.MaxLength Then
Text3.SetFocus
End If
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar