Trucchi VB   VB Tips 2   VB Tips 3   VB Tips 4  

VB Tips - Trucchi Visual Basic



Problema

Soluzione

Come faccio a creare un Validatore di password?

Hai Bisogno di un "Command1" e "Text1" e queesto codice:


Private Sub Command1_Click()

If text1.text = "password" then

Msgbox "Password corretta!"

end

end if

If text1.text <> "password" then

Msgbox "Password non corretta. Riprova."

end

end if

End Sub

Come posso creare un form che scompaia dopo 5 secondi?

Hai bisogno di un "Timer1", setta a 5000 l'intervallo del timer e inserisci questo codice :

Private Sub Timer1_Timer()

Unload Me

End Sub


Come posso Centrare un form sullo schermo?

Inserendo questo codice:

Private Sub Form_Load()

Form1.Move(Screen.width-form1.width)\2,(screen.height-form1.height)\2

End Sub

Come far scrollare il testo della barra del titolo?

Inserendo questo codice:

Private Sub Form_Load()

Call TitleScroll(Form1)

End Sub


Sub TitleScroll(frm As Form)

Dim X As Integer

Dim current As Variant

Dim Y As String

Y = frm.Caption

frm.Caption = ""

frm.Show

For X = 0 To Len(Y)

If X = 0 Then

frm.Caption = ""

current = Timer

Do While Timer - current < 0.1

DoEvents

Loop

GoTo done

Else:

End If

frm.Caption = Left(Y, X)

current = Timer

Do While Timer - current < 0.05

DoEvents

Loop

done:

Next X

End Sub


Come Catturare lo Schermo?

Hai bisogno di un "Command1" e "Picture1"

Inserisci questo codice:

'declares

DefInt A-Z

Declare Sub ReleaseDC Lib "User" (ByVal hWnd, ByVal hDC)

Declare Sub OpenClipBoard Lib "User" (ByVal hWnd)

Declare Sub EmptyClipBoard Lib "User" ()

Declare Sub SetClipBoardData Lib "User" (ByVal CBFormat, ByVal hBitMap)

Declare Sub CloseClipBoard Lib "User" ()

Declare Sub SelectObject Lib "GDI" (ByVal hDC, ByVal hObj)

Declare Sub DeleteDC Lib "GDI" (ByVal hDC)

Declare Sub BitBlt Lib "GDI" (ByVal DestDC, ByVal X, ByVal Y, ByVal BWidth, ByVal BHeight, ByVal SourceDC, ByVal X, ByVal Y, ByVal Constant&)

Declare Function CreateDC Lib "GDI" (ByVal Driver$, ByVal Dev&, ByVal O&, ByVal Init&)

Declare Function CreateCompatibleDC Lib "GDI" (ByVal hDC)

Declare Function CreateCompatibleBitmap Lib "GDI" (ByVal hDC, ByVal BWidth, ByVal BHeight)


Sub ScrnCap (Lt, Top, Rt, Bot)

rWidth = Rt - Lt

rHeight = Bot - Top

SourceDC = CreateDC("DISPLAY", 0, 0, 0)

DestDC = CreateCompatibleDC(SourceDC)

BHandle = CreateCompatibleBitmap(SourceDC, rWidth, rHeight)

SelectObject DestDC, BHandle

BitBlt DestDC, 0, 0, rWidth, rHeight, SourceDC, Lt, Top, &HCC0020

Wnd = Screen.ActiveForm.hWnd

OpenClipBoard Wnd

EmptyClipBoard

SetClipBoardData 2, BHandle

CloseClipBoard

DeleteDC DestDC

ReleaseDC DHandle, SourceDC

End Sub


Private Sub Command1_Click()

Form1.Visible = False

ScrnCap 0, 0, 640, 480

Form1.Visible = True

picture1 = Clipboard.GetData()

End Sub


Pagina Successiva >>


© N2A network 2007 by Naeem - naeem203(@)gmail.com - bollywood videos - scambio link - alberghi