Here's two examples of what you are looking for. They certainly have clues
MSDN
Click Here
DIC
Click Here
I hope they help.
Here's two examples of what you are looking for. They certainly have clues
MSDN
Click Here
DIC
Click Here
I hope they help.
I'm sorry Reverend Jim... I find the reasnoble alternative solution I provided quite acceptable and much more versatile. Not good coding? I'm sorry sweet heart, did I venture away from your solution. Find a bug in my solution and I'll reconsider the fact you aren't just power tripping. A down vote for an alternative... grow up.
I find this method really useful. AllowedCodes also holds values for Delete, BackSpace, Home, End, Numeric Keypad Numbers, Standard Numbers etc.
Private Sub TextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyDown
If Not (KeyAllowed(e.KeyCode)) Then e.SuppressKeyPress = True
End Sub
Private Function KeyAllowed(Key As System.Windows.Forms.Keys) As Boolean
Console.WriteLine(Key)
Dim AllowedCodes() As Byte = {35, 36, 46, 37, 38, 39, 40, 8, 189 _
, 45, 48, 48, 50, 51, 52, 53, 54, 55, 56, 57 _
, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 109}
If AllowedCodes.Contains(CInt(Key)) Then
Return True
Else
Return False
End If
End Function
I find this way you can ammend your allowed list with the greatest of ease.
-Hi Bud,
It looks like you are writing all the file bytes at once
strr.Write(file, 0, file.Length)
Typically when you want to generate a progress you need to write chunks of the file eg...
Using fs As New FileStream(localFile, FileMode.Open, FileAccess.Read, FileShare.None)
'This is the buffer that will hold the chunks to write
Dim buffer() As Byte = New Byte(2047) {}
'Only read 2kb of data per pass (thisfilesize is the length of the local file)
For offset As Integer = 0 To thisfilesize Step 2048
'Let's read 2kb of the local file
fs.Read(buffer, 0, buffer.Length)
'If the last piece of data is less then 2kb then we'll reduce the chunksize
Dim chunkSize As Integer = thisfilesize - offset
If chunkSize > 2048 Then chunkSize = 2048
'Write the buffer to the remote stream (Buffer Size in this case 2kb)
clsStream.Write(buffer, 0, chunkSize)
'Update progress if int(percent complete) has changed
If prevPerc <> Int((100 / thisfilesize) * (offset + chunkSize)) Then
Console.WriteLine(Int((100 / thisfilesize) * (offset + chunkSize)))
If boo_RunOnThread = True Then
setProgressValue(Int((100 / thisfilesize) * (offset + chunkSize)))
Else
prg_ProgresBar.Value = Int((100 / thisfilesize) * (offset + chunkSize))
End If
prevPerc = Int((100 / thisfilesize) * (offset + chunkSize))
End If
Next
End Using
Next
I hope this helps. Let me know if you have figured it out already or you need any help at all.