10 Tips and Trick Visual Basic From Vb Bego Forum

1.Denied deletion file, this trick are open the file for simultan so the windows couldn’t delete the file until the aplication end or stopped
Source Code :
Private Sub Form_Load()
timer1.interval = 1
End Sub

Private sub timer1_timer()
Open "PathFilenya" For Input As 1
End Sub
2.Random Coloured label, this trick will change your label each sec
Source Code :
Private Sub Timer1_Timer()
randomize()
Label1.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
End Sub
3.Set the Attributes file without API function
Source Code :
Private Sub Command1_Click()
Setattr pathname,vbhidden+vbsystem+vbreadonly
End Sub

'To make it normal
Private Sub Command1_Click()
Setattr pathname,vbnormal
End Sub
4. Animated form when unload
Source Code :
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
'The form go up
Do Until Me.Top <= -5000
DoEvents
Me.Move Me.Left, Me.Top – 10
DoEvents
Loop
Unload Me
End Sub

5.Gradiation Back Color Form
Source Code :
Private Sub Form_Load()
Form1.AutoRedraw = True
For x = 0 To ScaleHeight
Line (1, x)-(ScaleWidth, x), RGB(5, 10, 255 – (x * 255) \ ScaleHeight)
Next x

End Sub
6. Select all content in textbox the easiest way and always used by POS or accounting application just insert these code to event proc
Source Code :
SendKeys “{home}+{end}”
7. UnClosed Form
Source Code :
Private Sub Form_Unload (Cancel as Integer)
Cancel = 1
End Sub
8. ASCII Detector
Source Code :
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Me.Caption = KeyCode
End Sub
9. Check the existence of Folder or Files
Source Code :
'Check the Folder
If Dir$(Text1.Text, vbDirectory) = “” Then
msgbox “Folder Not Exist”, vbinformation
ElseIf Dir$(Text1.Text, vbDirectory) <> “” Then
msgbox “Folder Exist”, vbinformation
End If

'Check The File
If Dir(Text1.Text) = “” Then
msgbox “File Not Exist”, vbinformation
ElseIf Dir(Text1.Text) <> “” Then
msgbox “File Exist”, vbinformation
End If
10. Dragging the Form from around of your form
Source Code :
Private move_x As Integer
Private move_y As Integer
Private move_form As Boolean
Private Sub form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
move_x = X
move_y = Y
move_form = True
End Sub
Private Sub form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If move_form Then
Me.Move Me.Left + X – move_x, Me.Top + Y – move_y
DoEvents
End If
End Sub
Private Sub form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
move_form = False
End Sub



Related Post :



 
VB Source Code | © 2011 Design by DheTemplate.com and Theme 2 Blog

Find more free Blogger templates at DheTemplate.com - Daily Updates Free Blogger Templates