469,579 Members | 1,082 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,579 developers. It's quick & easy.

stop scanning and display msg box after scanning reach EOF

kirubagari
158 100+
For i = 49 To mfilesize Step 6

rich1.SelStart = Len(rich1.Text)


rich1.SelText = "Before : " & HexByte2Char(arrByte(i)) & _
" " & HexByte2Char(arrByte(i + 1)) & " " _
& HexByte2Char(arrByte(i + 2)) & " " _
& HexByte2Char(arrByte(i + 3)) & " " _
& HexByte2Char(arrByte(i + 4)) & " " _
& HexByte2Char(arrByte(i + 5)) _
& vbNewLine

If arrByte(i) <> a Then
arrByte(i) = a
changeMade = True

End If
If arrByte(i + 1) <> b Then
arrByte(i + 1) = b
changeMade = True
End If
If changeMade Then
AnyChanged = True
rich1.SelText = "After : " & HexByte2Char(arrByte(i)) & _
" " & HexByte2Char(arrByte(i + 1)) & " " _
& HexByte2Char(arrByte(i + 2)) & " " _
& HexByte2Char(arrByte(i + 3)) & " " _
& HexByte2Char(arrByte(i + 4)) & " " _
& HexByte2Char(arrByte(i + 5)) _
& " <--- Corrected" _
& vbNewLine

End If

Next




i want to popup msg box that will be display a msg that saying the scanning reach the last byte. It mean the scanning is finished.


this is the coding.is it correct?


if i=mfilesize then

msg box "SCANNNG IS FINISHED"
end if


and another question how to stop scanning when we wish to stop when the scanning is going on.what is the code
Jul 19 '07 #1
1 1348
Killer42
8,435 Expert 8TB
I don't think there's any need to check the value of your loop counter. Just put the MsgBox after the end of the loop. That is, after the Next statement.

Ok, here's a brief description of the sort of technique I use to interrupt a long-running process. I don't think there is really any "right" or "wrong" way (unless it doesn't work, of course, in which case it is wrong). But here's my way.
  • Create a global (or form-level) variable called UserWantsOut.
    The name is up to you, of course - that's just what I use. To make it global, place it in a code module (not a form) and use...
    Public UserWantsOut As Boolean
  • Place a button on your form labelled "Stop" or "Abort" or similar.
  • At the start of your process, show and/or enable the button, and set UserWantsOut to False.
  • At the end of your process, hide and/or disable the button.
  • In the click event procedure for the button, just do this...
    Expand|Select|Wrap|Line Numbers
    1. UserWantsOut = True
  • In your potentially long-running procedure, each time around the loop (or every 100 times, or 1,000 times or whatever), execute something like this...
    Expand|Select|Wrap|Line Numbers
    1. DoEvents ' <-- This is important.
    2. If UserWantsOut Then
    3.   Exit For
    4. End If

And in this case, after the Next statement I would do something like...
Expand|Select|Wrap|Line Numbers
  1. If UserWantsOut Then
  2.   MsgBox "Aborted by user!"
  3. Else
  4.   MsgBox "Finished!"
  5. End If
Jul 19 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by W. Cerven | last post: by
14 posts views Thread by S. Nurbe | last post: by
4 posts views Thread by tshad | last post: by
4 posts views Thread by =?Utf-8?B?YzY3NjIyOA==?= | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.