All Basic

Sanal Alemin En Büyük Vb Kod Arşivi

Visual Basic

Visual Basic, Microsoft tarafından, Basic programlama dili üzerinde geliştirilmiş, olay yönlendirmeli, üst seviye, nesne tabanlı ve görsel bir programlama dilidir.

AllBasic

Değişik Dosya Kopyalama

Componentler
command1->cmdbrowse
comamnd2->cmdcopy
text1->txtsrc
text2->txtdest
progressbar1
commondialog

CmdBrowse_Click:
CmnDlg.Filter = "All files|*.*"
CmnDlg.ShowOpen
TxtSrc.Text = CmnDlg.FileName

CmdCopy_Click:
On Error GoTo CopyErr

Dim SrcFile As String
Dim DestFile As String
Dim SrcFileLen As Long
Dim nSF, nDF As Integer
Dim Chunk As String
Dim BytesToGet As Integer
Dim BytesCopied As Long

CmdCopy.Enabled = False

SrcFile = TxtSrc
DestFile = TxtDest

SrcFileLen = FileLen(SrcFile)
'Progress bar settings
ProgressBar1.Min = 0
ProgressBar1.Max = SrcFileLen

nSF = 1
nDF = 2
Open SrcFile For Binary As nSF
Open DestFile For Binary As nDF

'How many bytes to get each time
BytesToGet = 4096 '4kb
BytesCopied = 0
ProgressBar1.Value = 0
LblPercent.Caption = "0"
Do While BytesCopied < SrcFileLen
If BytesToGet < (SrcFileLen - BytesCopied) Then
Chunk = Space(BytesToGet)
Get #nSF, , Chunk
Else
Chunk = Space(SrcFileLen - BytesCopied)
Get #nSF, , Chunk
End If
BytesCopied = BytesCopied + Len(Chunk)

ProgressBar1.Value = BytesCopied
LblPercent.Caption = Int(BytesCopied / SrcFileLen * 100)
LblPercent.Refresh

Put #nDF, , Chunk
Loop

ProgressBar1.Value = 0
'ProgressBar1.Visible = False

GoTo Ex
CopyErr:
MsgBox Err.Description, vbCritical, "Error"
Ex:
Close #nSF
Close #nDF
CmdCopy.Enabled = True