
Salvar el contenido de un
TextBox a un fichero en disco:
Añada el siguiente código:
Private Sub Command1_Click()
Dim canalLibre As Integer
'Obtenemos un canal libre que nos dará
'el sistema oparativo para poder operar
canalLibre = FreeFile
'Abrimos el fichero en el canal dado
Open "C:\fichero.txt" For Output As #canalLibre
'Escribimos el contenido del TextBox al fichero
Print #canalLibre, Text1
Close #canalLibre
End Sub
Provocar la trasparencia de un formulario:
Escribir el siguiente código:
Private Declare Function SetWindowLong Lib "user32" Alias
"SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long,
ByVal dwNewLong As Long) As Long
Private Sub Form_Load()
Dim Resp As Long
Resp = SetWindowLong(Me.hwnd, -20, &H20&)
Form1.Refresh
End Sub
Determinar si un fichero existe o no:
Escriba el siguiente código: (una de tanta maneras aparte de Dir$())
Private Sub Form_Load()
On Error GoTo Fallo
x = GetAttr("C:\Archivo.extención")
MsgBox "El fichero existe."
Exit Sub
Fallo:
MsgBox "El fichero no existe."
End Sub
Capturar la pantalla entera
o la ventana activa:
Añadir dos botones y escribir el siguiente código:
Private Declare Sub keybd_event Lib
"user32" (ByVal bVk As Byte,
ByVal bScan As Byte, ByVal dwFlags As Long,
ByVal dwExtraInfo As Long)
Private Sub Command1_Click()
'Captura la ventana activa
keybd_event 44, 0, 0&, 0&
End Sub
Private Sub Command2_Click()
'Captura toda la pantalla
keybd_event 44, 1, 0&, 0&
End Sub
Vaciar la carpeta de
Documentos de Windows:
Inicie un nuevo proyecto y añada el siguiente código:
Private Declare Function SHAddToRecentDocs Lib "Shell32" (ByVal lFlags As Long, ByVal lPv As Long) As Long Private Sub Form_Load() SHAddToRecentDocs 0, 0 End Sub
Abrir la ventana de Propiedades de agregar o quitar
aplicaciones:
Añada el siguiente código:
Private Sub Command1_Click()
X = Shell("Rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl
@0")
End Sub
Imprimir un RichTextBox tal y como se ve:
Imprimir un RichTextBox con su formato original.
Private Sub Command1_Click()
On Error GoTo ErrorDeImpresion
Printer.Print ""
RichTextBox1.SelPrint Printer.hDC
Printer.EndDoc
Exit Sub
ErrorDeImpresion:
Exit Sub
End Sub
Como crear un grupo de
programas:
Muy útil para crear instalaciones por ejemplo:
Añadir un textbox y hacerlo oculto.
Una vez oculto, escribir estas líneas sustituyendo "Nombre del
Grupo" por que se desea crear,
y que lo colocamos en Inicio -> Programas.
Private Sub Command1_Click()
Text1.LinkTopic = "Progman|Progman"
Text1.LinkMode = 2
Text1.LinkExecute "[CreateGroup(" + "Nombre del Grupo" + ")]"
End Sub