31-05-20, 07:17 AM
السلام عليكم ورحمة الله وبركاته
المثال يفي بالايضاح
PHP كود :
Public Class Form1
Dim dbpath As String = ""
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnselect.Click
dbpath = ""
Dim o As New OpenFileDialog
If o.ShowDialog = DialogResult.OK Then
dbpath = o.FileName
End If
btncheck.Enabled = dbpath.ToString.Trim.Length
ckcheck.Enabled = dbpath.ToString.Trim.Length
End Sub
Private Sub btncheck_Click(sender As Object, e As EventArgs) Handles btncheck.Click
lbl.Visible = False
Dim dir As String = IO.Path.GetDirectoryName(dbpath) & "\"
If ckcheck.Checked Then
Timer1.Start()
Else
Timer1.Stop()
Dim ldp As String = IO.Path.GetFileNameWithoutExtension(dbpath) & ".laccdb"
If IO.File.Exists(dir & ldp) Then
lbl.ForeColor = Color.Red
lbl.Text = "مستخدم"
Else
lbl.ForeColor = Color.Green
lbl.Text = "غير مستخدم"
End If
End If
lbl.Visible = True
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
lbl.Visible = False
If ckcheck.Checked Then
Dim dir As String = IO.Path.GetDirectoryName(dbpath) & "\"
Dim ldp As String = IO.Path.GetFileNameWithoutExtension(dbpath) & ".laccdb"
If IO.File.Exists(dir & ldp) Then
lbl.ForeColor = Color.Red
lbl.Text = "مستخدم"
Else
lbl.ForeColor = Color.Green
lbl.Text = "غير مستخدم"
End If
Else
Timer1.Stop()
End If
lbl.Visible = True
End Sub
Private Sub ckcheck_CheckedChanged(sender As Object, e As EventArgs) Handles ckcheck.CheckedChanged
Timer1.Enabled = ckcheck.Checked
End Sub
End Class