Sabtu, 25 September 2010

Status Form

Kode berikut ini akan membantu untuk mengetahui status dari Form, apakah sudah di-load (dibuka) atau belum.

Buat Module baru dan ketikkan :
[ VB 6.0 ]
Public Function IsLoaded(ByVal FormName As String) As Boolean
Dim i As Integer
IsLoaded = False
For i = 0 To Forms.Count - 1
If LCase(Forms(i).Name) = LCase(FormName) Then
IsLoaded = True
Exit Function
Exit For
End If
Next
End Function

[ VB .NET ]
Public Function IsLoaded(ByVal FormName As String) As Boolean
Dim i As Integer
IsLoaded = False
For i = 0 To Application.OpenForms.Count - 1
If Application.OpenForms.Item(i).Name.ToLower = FormName.ToLower Then
IsLoaded = True
Exit Function
Exit For
End If
Next
End Function



Untuk penggunaannya, misalkan Anda ingin mengecek status dari 'Form2', contoh kodenya sebagai berikut :
If IsLoaded("Form2") = True Then
'jika sudah di Load
Else
'jika belum di Load
End If

Label: , , ,

0 Komentar:

Posting Komentar

Pengunjung yang baik selalu meninggalkan jejak berupa komentar. :)

Berlangganan Posting Komentar [Atom]

<< Beranda