10-11-14, 08:27 PM (آخر تعديل لهذه المشاركة : 11-11-14, 02:07 AM {2} بواسطة مصطفى.)
السلام عليكم عندي شغله صغيرة عليكم ان شاء الله وهي عندي برنامج يعمل تصدير بيانات mysql بلغة vb.net 2008 كيف اعمل انتضار للمستخدم ريت ماينتهي التصدير وذلك لان الفورم يدخل في عمليه not responding فاطلب منكم عمل على سبيل المثال جاري عملية التصدير يرجى الانتضار لحد ما يكتمل التصدير ......................... وشكرا
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Start up the BackgroundWorker1.
للستدعاء الbackgrondworker
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, _
ByVal e As System.ComponentModel.DoWorkEventArgs) _
Handles BackgroundWorker1.DoWork
اعمل فورم الانتظار وستدعي هنا يفضل عمل timer للمصداقية ^_^
System.Threading.Thread.Sleep(1000)
End Sub
11-11-14, 12:02 PM (آخر تعديل لهذه المشاركة : 11-11-14, 12:08 PM {2} بواسطة مصطفى.)
[attachment=6032 كتب :
export.rar (الحجم : 211.24 ك ب / التحميلات : 106)
export.rar (الحجم : 211.24 ك ب / التحميلات : 106)
export.rar (الحجم : 211.24 ك ب / التحميلات : 106)
سعود pid='50435' dateline='1415658118']ابشر بالخير ...كنت ودي احيلك لرابط لكن خشيت ما يفيدك بشي.
لكن لو تقدر تصمم مثال بسيط بنفس الفكرة لديك واعيد المثال معدل بالطريقة الصحيحة ..
اسف رفعته ثلاث مرات هو نفسه لاكن بالخطا رفعته ثلاث مرات نزل الي تريد اي واحد من ملف export.rar
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, _
ByVal e As System.ComponentModel.DoWorkEventArgs) _
Handles BackgroundWorker1.DoWork
اعمل فورم الانتظار وستدعي هنا يفضل عمل timer للمصداقية ^_^
System.Threading.Thread.Sleep(1000)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Start up the BackgroundWorker1.
للستدعاء الbackgrondworker
BackgroundWorker1.RunWorkerAsync()
End Sub
End Class
اخي يوسف ممكن ترى المثال الذي رفعته وتعطيني خبرتك لكي اعمل انتضار وشكرا
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.ProgressBar1 = New System.Windows.Forms.ProgressBar()
Me.Label1 = New System.Windows.Forms.Label()
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.Label2 = New System.Windows.Forms.Label()
Me.Panel1 = New System.Windows.Forms.Panel()
Me.Panel1.SuspendLayout()
Me.SuspendLayout()
'
'ProgressBar1
'
Me.ProgressBar1.Location = New System.Drawing.Point(2, 0)
Me.ProgressBar1.Name = "ProgressBar1"
Me.ProgressBar1.RightToLeft = System.Windows.Forms.RightToLeft.Yes
Me.ProgressBar1.Size = New System.Drawing.Size(633, 35)
Me.ProgressBar1.TabIndex = 0
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(546, 6)
Me.Label1.Name = "Label1"
Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.Yes
Me.Label1.Size = New System.Drawing.Size(66, 24)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Label1"
'
'Timer1
'
Me.Timer1.Interval = 2
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(0, 6)
Me.Label2.Name = "Label2"
Me.Label2.RightToLeft = System.Windows.Forms.RightToLeft.Yes
Me.Label2.Size = New System.Drawing.Size(66, 24)
Me.Label2.TabIndex = 2
Me.Label2.Text = "Label2"
'
'Panel1
'
Me.Panel1.Controls.Add(Me.Label2)
Me.Panel1.Controls.Add(Me.Label1)
Me.Panel1.Location = New System.Drawing.Point(12, 46)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(612, 40)
Me.Panel1.TabIndex = 3
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(636, 89)
Me.ControlBox = False
Me.Controls.Add(Me.Panel1)
Me.Controls.Add(Me.ProgressBar1)
Me.Name = "Form1"
Me.Panel1.ResumeLayout(False)
Me.Panel1.PerformLayout()
Me.ResumeLayout(False)
End Sub
Friend WithEvents ProgressBar1 As System.Windows.Forms.ProgressBar
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Timer1 As System.Windows.Forms.Timer
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Panel1 As System.Windows.Forms.Panel
End Class
وانسخ هذا الكود في form1.vb
كود :
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = "يرجى الانتظار ......"
ProgressBar1.Value = 99
Timer1.Enabled = True
Label2.Text = "%99"
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Panel1.Visible = True Then
Panel1.Visible = False
Else
Panel1.Visible = False
End If
End Sub
End Class
ثم في form24.vb
عدل الكود تبعك كالتالي:
كود :
Option Explicit On
Public Class Form24
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form1.Show()
Me.Enabled = False
Dim sconecion As MySqlConnection
Dim sconecion1 As MySqlConnection
Sub _export()
Try
Dim serverstring As String = "server=192.168.0.1;user id=root;password=root;database=mustafa;Convert Zero Datetime=True;charset=utf8"
Dim fn As String = ""
sconecion = New MySqlConnection(serverstring)
sconecion.Open()
If sconecion.State = ConnectionState.Open Then
SaveFileDialog1.FileName = "mustafa" & DateTime.Now.ToString("yyyy-MM-dd HH-mm-yy") & ".sql"
If SaveFileDialog1.ShowDialog() <> System.Windows.Forms.DialogResult.OK Then Exit Sub
fn = SaveFileDialog1.FileName
Using cmd As New MySqlCommand()
Dim file As String = fn
Using mb As New MySqlBackup(cmd)
cmd.Connection = sconecion
mb.ExportToFile(file)
MsgBox("تم تصدير البيانات بنجاح!", MsgBoxStyle.Information, "برنامج تصدير البيانات")
sconecion.Close()
Me.Close()
End Using
End Using
Else
End If
Catch ex As Exception
MsgBox("تاكد من خدمة الشبكة او البيانات !", MsgBoxStyle.Critical, "برنامج استيراد وتصدير البيانات")
Form1.Dispose()
End Try
Form1.Dispose()
End Sub
Private Sub Form24_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
a<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.ProgressBar1 = New System.Windows.Forms.ProgressBar()
Me.Label1 = New System.Windows.Forms.Label()
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.Label2 = New System.Windows.Forms.Label()
Me.Panel1 = New System.Windows.Forms.Panel()
Me.Panel1.SuspendLayout()
Me.SuspendLayout()
'
'ProgressBar1
'
Me.ProgressBar1.Location = New System.Drawing.Point(2, 0)
Me.ProgressBar1.Name = "ProgressBar1"
Me.ProgressBar1.RightToLeft = System.Windows.Forms.RightToLeft.Yes
Me.ProgressBar1.Size = New System.Drawing.Size(633, 35)
Me.ProgressBar1.TabIndex = 0
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(546, 6)
Me.Label1.Name = "Label1"
Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.Yes
Me.Label1.Size = New System.Drawing.Size(66, 24)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Label1"
'
'Timer1
'
Me.Timer1.Interval = 2
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(0, 6)
Me.Label2.Name = "Label2"
Me.Label2.RightToLeft = System.Windows.Forms.RightToLeft.Yes
Me.Label2.Size = New System.Drawing.Size(66, 24)
Me.Label2.TabIndex = 2
Me.Label2.Text = "Label2"
'
'Panel1
'
Me.Panel1.Controls.Add(Me.Label2)
Me.Panel1.Controls.Add(Me.Label1)
Me.Panel1.Location = New System.Drawing.Point(12, 46)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(612, 40)
Me.Panel1.TabIndex = 3
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(636, 89)
Me.ControlBox = False
Me.Controls.Add(Me.Panel1)
Me.Controls.Add(Me.ProgressBar1)
Me.Name = "Form1"
Me.Panel1.ResumeLayout(False)
Me.Panel1.PerformLayout()
Me.ResumeLayout(False)
End Sub
Friend WithEvents ProgressBar1 As System.Windows.Forms.ProgressBar
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Timer1 As System.Windows.Forms.Timer
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Panel1 As System.Windows.Forms.Panel
End Class
وانسخ هذا الكود في form1.vb
كود :
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = "يرجى الانتظار ......"
ProgressBar1.Value = 99
Timer1.Enabled = True
Label2.Text = "%99"
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Panel1.Visible = True Then
Panel1.Visible = False
Else
Panel1.Visible = False
End If
End Sub
End Class
ثم في form24.vb
عدل الكود تبعك كالتالي:
كود :
Option Explicit On
Public Class Form24
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form1.Show()
Me.Enabled = False
Dim sconecion As MySqlConnection
Dim sconecion1 As MySqlConnection
Sub _export()
Try
Dim serverstring As String = "server=192.168.0.1;user id=root;password=root;database=mustafa;Convert Zero Datetime=True;charset=utf8"
Dim fn As String = ""
sconecion = New MySqlConnection(serverstring)
sconecion.Open()
If sconecion.State = ConnectionState.Open Then
SaveFileDialog1.FileName = "mustafa" & DateTime.Now.ToString("yyyy-MM-dd HH-mm-yy") & ".sql"
If SaveFileDialog1.ShowDialog() <> System.Windows.Forms.DialogResult.OK Then Exit Sub
fn = SaveFileDialog1.FileName
Using cmd As New MySqlCommand()
Dim file As String = fn
Using mb As New MySqlBackup(cmd)
cmd.Connection = sconecion
mb.ExportToFile(file)
MsgBox("تم تصدير البيانات بنجاح!", MsgBoxStyle.Information, "برنامج تصدير البيانات")
sconecion.Close()
Me.Close()
End Using
End Using
Else
End If
Catch ex As Exception
MsgBox("تاكد من خدمة الشبكة او البيانات !", MsgBoxStyle.Critical, "برنامج استيراد وتصدير البيانات")
Form1.Dispose()
End Try
Form1.Dispose()
End Sub
Private Sub Form24_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
الاخ يوسف المحترم انا مشكلتي ماقدر اعمل انتضار مو مشكلة الفورم لايعمل معي انا حذفت الفورمات لاني اريد القاري يركز على form24 هذا شي اذا تقدر تفيدنا بعمل انتضار ....... نكون ممنونين منك وللعلم عندي فجوال ستوديو 2012