0

Not a duplicate of the suggested question, because I know how to call the functions and everything works fine. My question is about identifying/declaring the property in the VB6 code and not trying to get it to work.

I wrote a small library in C#, compiled for COM visibility/use, etc. All is well, I can use it in VB6 no sweat. I declared the functions in VB6, again, all is well. But I have a property in the library that I just don't know how to declare it in VB6.

I can use it just fine, but how do I actually declare it? I don't even know if this would be the correct terminology.

The library has 3 methods and 1 property. Methods are CreateHash, Encrypt, Decrypt. The property is Salt.

Everything is fully working, I just don't know how to show that the property exists and that it's for the library.

Some VB6 code (minus the commenting character for syntax highlighting):

Private Declare Function CreateHash Lib "CryptoLibrary.dll" (plainText As String) As String
Private Declare Function Encrypt Lib "CryptoLibrary.dll" (plainText As String, key As String) As String
Private Declare Function Decrypt Lib "CryptoLibrary.dll" (cipher As String, key As String) As String
//Somehow show that the Salt property exists

Private Sub Form_Load()

Dim c As New Crypto
Dim textToHash As String
Dim textToEncrypt As String
Dim encryptionKey As String

textToHash = "hash this text"
textToEncrypt = "encrypt this text"
encryptionKey = "ThisIsTheKey"
c.Salt = "SomeSalt" //works, but how do I "declare" it?

Dim hash As String
hash = c.CreateHash(textToHash)
Debug.Print "hash: " & hash

Dim cipher As String
cipher = c.Encrypt(textToEncrypt, encryptionKey)
Debug.Print "cipher: " & cipher

Dim plainText As String
plainText = c.Decrypt(cipher, encryptionKey)
Debug.Print "plainText: " & plainText

End Sub

EDIT: Showing the output from the debug window, to show that it works perfectly fine and that's not what this question is about. Again, the library is working in VB6 just fine.

hash: 09umCBt/Fx7F+kaHGCsmnAtG53p4YRrSaBgtiowkW0A= cipher: gJcImw14MOvqyGK/ToHMhnzgnigzAaeVylcrldvRBdFz+Gg5VGayhsAGogrYz8RT plainText: encrypt this text

sdouble
  • 1,055
  • 3
  • 11
  • 28
  • Have you set the ComVisible to true in the assembly on the C# side? – t0mm13b May 27 '16 at 21:18
  • @t0mm13b yes. Everything is good to go and works fantastically. My question is about properly identifying the "Salt" property from the library in the VB6 declarations. It's more of a "paper trail" than a necessity. – sdouble May 27 '16 at 21:22
  • @t0mm13b Thank you, that's more along the lines of what I'm looking for. Is getting it working with intellisense the only way to show that the property exists? I was hoping to somehow get it mentioned in the declarations so it's easy to notice. – sdouble May 27 '16 at 21:42
  • Its not clear what you are asking. Libraries dont have methods, classes do. Properties need not be declared to be consumed/imported. – Ňɏssa Pøngjǣrdenlarp May 27 '16 at 21:45
  • 2
    show the c# side of the code... – t0mm13b May 27 '16 at 22:05
  • This line declares it `Dim c As New Crypto` the compiler looks up your Crypto object's *type library* to get the function calls. –  May 29 '16 at 01:05

0 Answers0