Showing posts with label Form. Show all posts
Showing posts with label Form. Show all posts

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

Menonaktifkan tombol Maximize yang terdapat di MDIForm

0 comments
Source Code :
Option Explicit

Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" (ByVal hWnd As Long, _
ByVal nIndex As Long) As Long

Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" (ByVal hWnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) _
As Long

Private Const GWL_STYLE = (-16)
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_MAXIMIZEBOX = &H10000

Public Sub NoMaxBox(f As MDIForm)
Dim l As Long
l = GetWindowLong(f.hWnd, GWL_STYLE)
l = l And Not (WS_MAXIMIZEBOX)
l = SetWindowLong(f.hWnd, GWL_STYLE, l)
End Sub

Public Sub NoMinBox(f As MDIForm)
Dim l As Long
l = GetWindowLong(f.hWnd, GWL_STYLE)
l = l And Not (WS_MINIMIZEBOX)
l = SetWindowLong(f.hWnd, GWL_STYLE, l)
End Sub

Private Sub MDIForm_Load()
NoMaxBox Me 
'NoMinBox Me
End Sub

Private Sub MDIForm_Resize()
'Ganti 4800 di bawah dgn lebar form yg fix Anda tentukan
'Ganti 3600 di bawah dgn tinggi form yg fix Anda tentukan
If Me.Width <> 4800 Then Me.Width = 4800
If Me.Height <> 3600 Then Me.Height = 3600
End Sub

Disable Tombol Maximize di MDIForm

0 comments
Source Code :
Option Explicit

Private Declare Function GetWindowLong Lib "user32" _
        Alias "GetWindowLongA" (ByVal hWnd As Long, _
        ByVal nIndex As Long) As Long

Private Declare Function SetWindowLong Lib "user32" _
        Alias "SetWindowLongA" (ByVal hWnd As Long, _
        ByVal nIndex As Long, ByVal dwNewLong As Long) _
        As Long

Private Const GWL_STYLE = (-16)
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_MAXIMIZEBOX = &H10000

Public Sub NoMaxBox(f As MDIForm)
  Dim l As Long

  l = GetWindowLong(f.hWnd, GWL_STYLE)
  l = l And Not (WS_MAXIMIZEBOX)
  l = SetWindowLong(f.hWnd, GWL_STYLE, l)
End Sub

Public Sub NoMinBox(f As MDIForm)
  Dim l As Long

  l = GetWindowLong(f.hWnd, GWL_STYLE)
  l = l And Not (WS_MINIMIZEBOX)
  l = SetWindowLong(f.hWnd, GWL_STYLE, l)
End Sub

Private Sub MDIForm_Load()
  NoMaxBox Me
  'NoMinBox Me
End Sub

Private Sub MDIForm_Resize()
  'Ganti 4800 di bawah dgn lebar form yg fix Anda tentukan
  'Ganti 3600 di bawah dgn tinggi form yg fix Anda tentukan
  If Me.Width <> 4800 Then Me.Width = 4800
  If Me.Height <> 3600 Then Me.Height = 3600
End Sub

Make a form with a gradient background

Source Code :
'Make a form with a gradient background
'make a gradient form
'take a new form
'put a line on it: index number = 0
'a label with some text: set the BackStyle = transparant
'and put the next code on the form
'press F5
'you can make any change and use it
'in combination with splashscreen
'just enter the appropiate code

Private sub Form_Load()
    Dim k%

    Const afstand = 15
    Const vSKleur = &HFF   

    on Error Resume Next
    Line1(0).X1 = 0: Line1(0).Y1 = 0
    Line1(0).X2 = form1.Width: Line1(0).Y2 = 0
    Label1.Width = form1.Width
    Label1.Move 0, 0
    Label1.Align = 2
    Me.Show

    Screen.MousePointer = vbHourglass
    For k = 1 To (form1.Height / Afstand)
        DoEvents
        Load Line1(k)
        Line1(k).X1 = 0: Line1(k).Y1 = Line1(k - 1).Y1 + Afstand
        Line1(k).X2 = form1.Width: Line1(k).Y2 = Line1(k - 1).Y1 + Afstand
        Line1(k).BorderColor = vSKleur * Int(vSKleur * (k / (form1.Height / Afstand)))
        Line1(k).Visible = True
    Next k

    Screen.MousePointer = vbNormal
End Sub

Private sub Form_KeyPress(KeyAscii as Integer)
    Unload form1   
End Sub

Private sub Form_Unload(Cancel as Integer)
    End
End Sub

Return
 
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