Sunteți pe pagina 1din 2

Trucos en Visual Basic Pasar de un TextBox a otro al pulsar Enter:

Insertar tres TextBox y escribir el siguiente cdigo: Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then SendKeys "{tab}" KeyAscii = 0 End If End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then SendKeys "{tab}" KeyAscii = 0 End If End Sub Private Sub Text3_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then SendKeys "{tab}" KeyAscii = 0 End If End Sub otra forma: Insertar tres TextBox, cambiar la propiedad KeyPreview del formulario a True y escribir el siguiente cdigo: Private Sub Form_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then SendKeys "{tab}" KeyAscii = 0 End If End Sub

Apagar el equipo, reiniciar Windows, reiniciar el Sistema:


Aadir tres botones a un formulario y escribir lo siguiente en el cdigo del formulario: Private Declare Function ExitWindowsEx& Lib "user32" (ByVal uFlags&, ByVal dwReserved&) Private Sub Command1_Click() Dim i as integer i = ExitWindowsEx(1, 0&) 'Apaga el equipo End Sub Private Sub Command2_Click() Dim i as integer i = ExitWindowsEx(0, 0&) 'Reinicia Windows con nuevo usuario End Sub Private Sub Command3_Click() Dim i as integer i = ExitWindowsEx(2, 0&) 'Reinicia el Sistema

Forzar a un TextBox para que admita nicamente nmeros:


Crear un formulario, aadir un TextBox y escribir el siguiente cdigo:

Sub Text1_Keypress(KeyAscii As Integer) If KeyAscii <> Asc("9") Then 'KeyAscii = 8 es el retroceso o BackSpace If KeyAscii <> 8 Then KeyAscii = 0 End If End If End Sub

S-ar putea să vă placă și