ขอถามนะครับถ้าจะเอาโค้ด 1 แทรกลงในโค้ด 2 จะต้องเขียนอย่างไรครับ ขอบคุณครับ
---โค้ด1----
Private Sub import_Click()
Dim strPath As String
Dim strFile As String
Dim strTable As String
Dim StrFileName As String
Dim strextensionNew As String
strTable = "Table1"
strPath = "D:\textfile\"
strFile = Dir(strPath & "*.txt")
If strFile = "" Then
MsgBox "ไม่พบไฟล์ที่จะ Import !!", vbCritical, "แจ้งเตือน"
Exit Sub
End If
Do While strFile <> ""
StrFileName = strPath & strFile
DoCmd.TransferText acImportDelim, "", strTable, StrFileName, False
strextensionNew = Left(StrFileName, InStrRev(StrFileName, ".") - 1) & ".xxx"
Name StrFileName As strextensionNew
strFile = Dir
Loop
End Sub
---โค้ด2---
Option Compare Database
Option Explicit
Dim holdPercComplete As Single
Private Sub UpdateProgress(CurrentItem As Long, TotalItems As Long, taskName As String)
Dim PercComplete As Single
Dim intWidth As Integer
Me.lblCurrentTask.Caption = taskName
'Validate data
If CurrentItem <= 0 Or TotalItems <= 0 Then
imgProgress.Width = 0
Exit Sub
End If
'Calculate the percentage complete
PercComplete = CurrentItem / TotalItems
If Int(PercComplete * 100) = Int(holdPercComplete * 100) Then
Exit Sub
End If
'Save it for comparison
holdPercComplete = PercComplete
'Calculate how wide to make the progress bar
If (PercComplete * 100) Mod 5 = 0 Then
intWidth = (BoxProgress.Width * PercComplete)
imgProgress.Width = intWidth
DoEvents 'or Me.Repaint
End If
End Sub
Private Sub Form_Load()
Call UpdateProgress(0, 0, "Idle")
End Sub
Private Sub cmdStart_Click()
Dim lngItem As Long
Const lngTotal As Long = 100000
Do While lngItem <= lngTotal
lngItem = lngItem + 1
If lngItem < 50000 Then
Call UpdateProgress(lngItem, lngTotal, "Starting...")
ElseIf lngItem < 75000 Then
Call UpdateProgress(lngItem, lngTotal, "Getting there...")
Else
Call UpdateProgress(lngItem, lngTotal, "Almost finished...")
End If
Loop
Call UpdateProgress(lngItem, lngTotal, "Task complete")
End Sub