| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| I've never utilized a VB Class module before and I am trying to incorporate an MD5 Hashing Class I downloaded into a simple test project. I've looked thru some MSDN info and can't see what I may be missing with regards to calling a public class function. I have an ultra-simple form interface to point to a file for which I want to generate the hash code. Below is the code I use to get a filepath, instantiate a class into an object, and attempt to call the public class function: - - - - - - - - - - - - - - Option Explicit Public HashTool As MD5 'Class is named MD5 Private Sub Command1_Click() Dim strFinalMD5Value As String cdbPath.ShowOpen lblSourcePath.Caption = cdbPath.FileName strFinalMD5Value = HashTool.DigestFileToHexStr(lblSourcePath.Caption) lblHashCode.Caption = strFinalMD5Value End Sub - - - - - - - - - - - - - - An error is raised "Run Time Error 91", "Object Variable or With Block not Set". This error occurs a the line where I attempt to invoke the class function: "HashTool.DigestFileToHexStr()" - - - - - - - - - - - - - - I don't know if this error is actually occurring due to the code contained within the class function, and so I am including it here just in case ... Public Function DigestFileToHexStr(FileName As String) As String Open FileName For Binary Access Read As #1 MD5Init Do While Not EOF(1) Get #1, , ByteBuffer If Loc(1) < LOF(1) Then ByteCounter = ByteCounter + 64 MD5Transform ByteBuffer End If Loop ByteCounter = ByteCounter + (LOF(1) Mod 64) Close #1 MD5Final DigestFileToHexStr = GetValues End Function Public Sub MD5Init() ByteCounter = 0 State(1) = UnsignedToLong(1732584193#) State(2) = UnsignedToLong(4023233417#) State(3) = UnsignedToLong(2562383102#) State(4) = UnsignedToLong(271733878#) End Sub .. . . lots of bitwise manipulations galore follow ... Thanks for any input, --Steve |
|
#2
| |||
| |||
| On Thu, 4 Sep 2008 11:28:23 -0700 (PDT), stevegdula@yahoo.com wrote: >I've never utilized a VB Class module before and I am trying to >incorporate >an MD5 Hashing Class I downloaded into a simple test project. > You don't appear to be 'creating' the class, in your Click event you need; Set HashTool = New MD5 -- Alfie [UK] <http://www.delphia.co.uk/> Girl power is fine - But who do you call when a fuse blows ? |
|
#3
| |||
| |||
| That did the trick. Thank you. Just to be safe I used "Set HashTool = Nothing" at the end to assure I cleaned up the memory for this object. I'm not sure if it is otherwise automatic after the procedure ends. ~Steve On Sep 4, 4:30*pm, "Alfie [UK]" <al...@mail.invalid> wrote: > On Thu, 4 Sep 2008 11:28:23 -0700 (PDT), stevegd...@yahoo.com wrote: > >I've never utilized a VB Class module before and I am trying to > >incorporate > >an MD5 Hashing Class I downloaded into a simple test project. > > You don't appear to be 'creating' the class, in your Click event you > need; > > Set HashTool = New MD5 > -- > Alfie [UK] > <http://www.delphia.co.uk/> > Girl power is fine - But who do you call when a fuse blows ? |
|
#4
| |||
| |||
| stevegdula@yahoo.com's wild thoughts were released on Thu, 4 Sep 2008 15:45:48 -0700 (PDT) bearing the following fruit: >That did the trick. Thank you. > >Just to be safe I used "Set HashTool = Nothing" at the end >to assure I cleaned up the memory for this object. I'm not >sure if it is otherwise automatic after the procedure ends. It should be automatic but it still nice to do since it clearly documents your intention. >~Steve > > >On Sep 4, 4:30*pm, "Alfie [UK]" <al...@mail.invalid> wrote: > >> On Thu, 4 Sep 2008 11:28:23 -0700 (PDT), stevegd...@yahoo.com wrote: >> >I've never utilized a VB Class module before and I am trying to >> >incorporate >> >an MD5 Hashing Class I downloaded into a simple test project. >> >> You don't appear to be 'creating' the class, in your Click event you >> need; >> >> Set HashTool = New MD5 >> -- >> Alfie [UK] >> <http://www.delphia.co.uk/> >> Girl power is fine - But who do you call when a fuse blows ? -- Jan Hyde (VB MVP) https://mvp.support.microsoft.com/profile/Jan.Hyde |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.