de Grenville Tryon Pera      

Aplicaciones

Controles

Trucos

Preguntas

Teoria

Internet

Enlaces

Casos

Surf

Las paginas de Visual Basic

Pagina  1 2  3 4 5 6 7 8 9 10 11 12 13 14 15

 

51 Solo letras en un textbox   Limitar un textbox para que recba solo letras
52 Apagar PC desde VB   Apagar la PC desde VB
53 Mostrar un Richtextbox de colores   Como trabajar un richtextbox
54 Leer un archivo ASCII ubicar un texto en el   Leer un archivo ASCII, hallar un texto en el
55 Limitar el mouse a una region de una pantalla   Limitar el desplazamiento del mouse
56 Error de conversion en SQL 6.5   Error de conversion en SQL 6.5
57 Seleccionar datos de dos BD distintas   Seleccionar datos de dos baes de datos distintas
58 Funciones API para Internet   Funciones API ara saber si se esta conectado a Internet
59 Funciones para trabajar registros   Funciones ara trabajar registros
60 Mandar un archivo por Email   Mandra por email un archivo

 

Solo letras en un text
Private Sub txtTuTextBox_KeyPress(KeyAscii As Integer)
If KeyAscii < 65 Or KeyAscii >122 Then
KeyAscii = 0
End If
End Sub

Apagar PC desde VB
Declare Function ExitWindows Lib "user32" Alias "ExitWindowsEx" (ByVal dwReserved As Long, ByVal uReturnCode As Long) As Long
varlong = ExitWindows (0, EW_REBOOT)
o
varlong = ExitWindows (0, EW_SHUTDOWN)

Mostrar un texto (Rich Text) con distintos colores
Sub Form_load()
Dim dBase as Database
Dim rTabla as RecordSet
Dim FechaAyer as Date
Set dBase=OpenDatabase(CURDIR() & "\Contabilidad.mdb")
FechaAyer=DATE(Daye()-1)
Set rTabla=dBase.OpenRecordset("SELECT * FROM ASIENTOS WHERE _ FECHA= ' " & Format(FechaAyer,"dd/mm/yy") & " ' "
While not rTabla.eof
RTB.SelColor=vbBlue
RTB.SelText=rTabla("FECHA")
RTB.SelColor=vbBlack
RTB.SelText=rTabla("CUENTA")
IF rTabla("HABER_DEBE")="D" Then
RTB.SelText=vbGreen
RTB.SelText=rTabla("IMPORTE")
Else
RTB.SelText=vbRed
RTB.SelText="-" & rTabla("IMPORTE")
RTB.SelText=vbCrLf
Endif
rTabla.MoveNext
Wend

Leer un ASCCI, y ubicar una palabra en el
open "archivo.txt" for input as #1 'abre el archivo texto para leerlo
do while not eof(1) 'loop para buscar el renglon donde tiene la palabra password
line input #1,texto 'lee un renglon a la vez
x=instr(texto,"password") 'busca en el texto existe la palabra password
if x<> 0 then 'si x es diferente a 0 entonces si contiene password
end if
loop

Limitar el desplazamiento del mouse a una region de la pantalla
Option Explicit
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
Public Sub DisableTrap(CurForm As Form)
Dim erg As Long
Dim NewRect As RECT
CurForm.Caption = "Mouse released"
With NewRect
.Left = 0&
.Top = 0&
.Right = Screen.Width / Screen.TwipsPerPixelX
.Bottom = Screen.Height / Screen.TwipsPerPixelY
End With
erg& = ClipCursor(NewRect)
End Sub
Public Sub EnableTrap(CurForm As Form)
Dim x As Long, y As Long, erg As Long
Dim NewRect As RECT
x& = Screen.TwipsPerPixelX
y& = Screen.TwipsPerPixelY
CurForm.Caption = "Mouse trapped"
With NewRect
.Left = CurForm.Left / x&
.Top = CurForm.Top / y&
.Right = .Left + CurForm.Width / x&
.Bottom = .Top + CurForm.Height / y&
End With
erg& = ClipCursor(NewRect)
End Sub
Private Sub Command1_Click()
EnableTrap Form1
End Sub
Private Sub Command2_Click()
DisableTrap Form1
End Sub
Private Sub Form_Unload(Cancel As Integer)
DisableTrap Form1
End Sub

Error de conversion en SQL 6.5
There is a bug in SQL 6.5 concerning rounding. Your best bet is to use the CONVERT function with the NUMERIC() datatype:
CONVERT(NUMERIC(8,2), Price)

Seleccionar (SP) desde dos bases de datos distintas:
select a.numgui, a.codcli, b.nomcli, b.numruc from Almacen.dbo.tabla1 a, Maestros.dbo.tabla2 b where a.codcli = b.codcli

Funciones API para saber si se esta conectado a Internet:
RASEnumConnections y RASCount.

Funciones para trabajar registros
Sub Form_Unload()
SaveSetting "Proyecto", "MainForm", "Left", Me.Left
SaveSetting "Proyecto", "MainForm", "Top", Me.Top
SaveSetting "Proyecto", "MainForm", "Width", Me.Width
SaveSetting "Proyecto", "MainForm", "Height", Me.Height
End Sub
Sub Form_Load()
Me.Left = GetSetting("Proyecto", "MainForm", "Left", Me.Left)
Me.Top = GetSetting("Proyecto", "MainForm", "Top", Me.Top)
Me.Width = GetSetting("Proyecto", "MainForm", "Width", Me.Width)
Me.Height = GetSetting("Proyecto", "MainForm", "Height", Me.Height)
End Sub

Mandar un archivo por E-Mail
Private Sub Command1_Click()
rep1.ReportFileName = "C:\Informe.rpt" 'Nombre del informe
rep1.Destination = crptToFile
rep1.PrintFileName = "C:\MiDocumento.doc" 'Documento Word en el meto el
report
rep1.PrintFileType = crptWinWord
rep1.Action = 1
MAPISession1.SignOn
MAPIMessages1.SessionID = MAPISession1.SessionID
MAPIMessages1.AddressCaption = "donosti@sicsa.es"
MAPIMessages1.MsgIndex = -1
MAPIMessages1.MsgSubject = "ESTE EL EL ASUNTO"
MAPIMessages1.MsgNoteText = "Quiero que aparezca esto en el mensaje, además del report"
MAPIMessages1.AttachmentPathName = "C:\MiDocuemnto.DOC"
MAPIMessages1.AttachmentName = "MiDocuemnto.DOC"
MAPIMessages1.AttachmentIndex = 0
MAPIMessages1.RecipDisplayName = "donosti@sicsa.es"
MAPIMessages1.Send
MAPISession1.SignOff
End Sub