Reputation: 375
I'm trying to pass values to a backgroundworker. I previously posted to ask how it could be done here. An answer directed me to this code, but I'm having issues trying to use it. Here's what I'm doing:
Class MyParameters
Friend strInputFile As String
Friend strOutputFile As String
Friend bytKey As Byte
Friend bytIV As Byte
Friend Direction As New CryptoAction
End Class
.
Private Sub bnEcrypt_Click(sender As Object, e As EventArgs) Handles bnEcrypt.Click
Dim bytKey As Byte()
Dim bytIV As Byte()
'Send the password to the CreateKey function.
bytKey = CreateKey(txtPass.Text)
'Send the password to the CreateIV function.
bytIV = CreateIV(txtPass.Text)
Dim m As New MyParameters
m.strInputFile = txtFile.Text
m.strOutputFile = txtPlaceIn.Text
m.bytKey = bytKey
m.bytIV = bytIV
m.Direction = CryptoAction.ActionDecrypt
But I'm getting a error: Value of type '1-dimensional array of byte' cannot be converted to a byte'. on these two:
m.bytKey = bytKey
m.bytIV = bytIV
Any help?
Upvotes: 2
Views: 6724
Reputation: 6608
Your class needs to accept a Byte()
instead:
Class MyParameters
Friend strInputFile As String
Friend strOutputFile As String
Friend bytKey As Byte() ' <-- Changed from Byte
Friend bytIV As Byte() ' <-- Changed from Byte
Friend Direction As New CryptoAction
End Class
Upvotes: 2
Reputation: 700910
You have declared two byte fields in the class. Declare two arrays instead:
Friend bytKey() As Byte
Friend bytIV() As Byte
Upvotes: 1
Reputation: 157136
You have your variables defined as a Byte
instead of a byte array Byte()
.
Use this:
Friend bytKey As Byte()
Friend bytIV As Byte()
Upvotes: 2