Hi guys. I'm new to this forum.

I have noticed this behaviour in a vb6 app of mine :

i have a public variable let's call it Number and two buttons cmd1, cmd2. cmd1 calls a function from a custom .dll of mine and also assigns a value to Number variable. If i then press cmd2 button i display a message with Number value. The issue is that it always displays 0 as if Number variable was not public but local. If in cmd1 i don't call the .dll function there is no such weird behaviour.

code :

Code:
Option Explicit

Public Number As Integer
Private Declare Function DllMain2 Lib "G:\1\testdll.dll" () As Boolean

Public Sub Command1_Click()
    
    Dim bb As Boolean
        
    bb = DllMain2
    Number = 5
    
End Sub

Public Sub Command3_Click()

    MsgBox (Number)

End Sub
so i press command1, then command2 button it the messagebox always displays 0 unless i don't call dllmain2 function. thank you in advance for your help