Results 1 to 13 of 13

Thread: Please Help. Expression Expteted with ByVal Sub Call

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Colorado
    Posts
    83

    Angry Please Help. Expression Expteted with ByVal Sub Call

    I keep getting an Expression Expected Error in this first section with both the ByVal underlined. Im simply trying to call the Encrypt Sub... I am loosing my mind with this. I tryed just
    Encrypt() but then I get errors about the System.IO.FileSystemEventArgs not being including in the call....

    If anyone has some ideas please share.


    VB Code:
    1. Private Sub btnEncrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncrypt.Click
    2.  
    3.         'Call the first encryption method with the error handler.
    4.  
    5.         Encrypt(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs)
    6.  
    7.  
    8.     End Sub


    Here is the Encrypt sub that I am trying to call. Everything here is fine.


    VB Code:
    1. Public Sub Encrypt(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs)
    2.         'Ignore the temp files that are being encrpyted.
    3.         If System.IO.Path.GetExtension(e.FullPath) = tempExt Then Exit Sub
    4.  
    5.  
    6.         Do
    7.             Try
    8.                 'Encrypt the file that is being created.
    9.                 EncryptFile(e.FullPath, pwBytes)
    10.                 ' Exit if successful
    11.                 Exit Do
    12.             Catch ex As Exception
    13.                 Dim attempts As Integer
    14.                 attempts += 1
    15.                 ' Make up to 10 attempts.
    16.                 If attempts > 10 Then Exit Sub
    17.                 ' Wait for a while and retry the operation.
    18.                 System.Threading.Thread.Sleep(1000)
    19.             End Try
    20.         Loop
    21.  
    22.     End Sub
    12/32/84 - I need some code to make me a sandwhich.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Wouldn't this call suffice? I don't do VB.Net, but it seems logical to me.
    Code:
    Encrypt(sender, e)
    Or at least, I wouldn't understand anyone uses VB.Net if this wouldn't suffice.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    You ar right cornbee
    Dont gain the world and lose your soul

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Colorado
    Posts
    83
    Didnt work. Got:

    Too many arguments to 'Public Sub Encrypt(e As System.IO.FileSystemEventArgs)'.

    With e underlined..

    Tryed just Encrypt(Sender) and it took it, but then I get a cast exeption when I click on the button. I'm at a loss. This is the only potion of the app tha is giving me problems.
    12/32/84 - I need some code to make me a sandwhich.

  5. #5
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Where are you getting this function from. did you write it yourself?
    Dont gain the world and lose your soul

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Colorado
    Posts
    83
    Im getting the code from a Windows service that creates a Dir on your hd. Files that are copied into the folder get encypted.

    I'm getting the original from a book (Programming Microsoft Visual Basic .NET)

    Only parts of the code are from the book. I'm just making it a windows app rather then a service. So the idea is that when the user clicks on the btnEncrypt button the files in the folder would then be encrypted.. Atleast thats the idea. And it wont work!
    12/32/84 - I need some code to make me a sandwhich.

  7. #7
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Ok, I see. The encrypt function you are trying to call should be wired to an event. The function is looking for 2 objects. The sender is the object on which the event was raised, and e is the arguments from the objects.

    Post the project and I'll take a look at it.
    Dont gain the world and lose your soul

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Colorado
    Posts
    83
    Deleted code.
    Last edited by Jes|er; Jan 21st, 2003 at 12:41 AM.
    12/32/84 - I need some code to make me a sandwhich.

  9. #9
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Dude attached the file.
    Dont gain the world and lose your soul

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Colorado
    Posts
    83
    Sorry. Didnt know I could.

    Thanks again.
    Attached Files Attached Files
    12/32/84 - I need some code to make me a sandwhich.

  11. #11
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    This is kicking my ass. Explain what you are trying to do. I'll give it another go in the morning.
    Dont gain the world and lose your soul

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Colorado
    Posts
    83
    Well, when the program starts it creates a dir - C:\Encrypt
    and starts to watch to watch the dir for changes (FSW - FileSystemWatcher). So if a file gets copied into that folder it
    automatically encrypts it. The problem is that the file(s) has to to be copied; I just havent found a way around this yet. So my plan is to open the dir when the user clicks: btnOpenDir.

    At this point the user can just drag files they want encrypted into the folder and then click: btnEncrypt. Which is where I am having the problem.

    The encryption process works like it should. As a matter of fact it works like I said by just copying files into the dir. But just not whith the click event.

    So basically I am trying to stimulate the encrytion process with the click event for the files that are already in the dir.

    Also when encrypted files are placed in, and the button pressed they get decrypted but thats not valid to the problem.

    I hope that makes sense.
    12/32/84 - I need some code to make me a sandwhich.

  13. #13
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Either change
    Public Sub Encrypt(ByVal e As System.IO.FileSystemEventArgs)
    to
    Public Sub Encrypt(ByVal o As System.Object, ByVal e As System.IO.FileSystemEventArgs)

    or
    Encrypt(o, e)
    to
    Encrypt(e)
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width