1 of 1 people found this helpful
I'm pretty sure you should be sending it an array of Byte() rather than a String, but if you want to use a String, initialize it with a long string of blanks so it is large enough to hold the value you expect.
I would really, strongly recommend you replace PI-API with at least PI-SDK in your VS 2008 environment, and preferably AF SDK.
I would like to use PI-SDK but I have so many works to do, for now I want to fix it first.
I changed my declare to:
Declare Function pisn_getsnapshotx Lib "piapi32.dll" (ByVal PtNum As Integer, ByRef drVal As Double, _
ByRef iVal As Integer, ByRef bVal As Byte(), ByRef bSize As Integer, ByRef iStat As Integer, _
ByRef Flags As Short, ByRef time0 As PiTimeStamp) As Integer
My VB code changed to:
Dim sString() As Byte
piErr = pisn_getsnapshotx(PiPtNum, TagValue, iVal, sString, bSize, iStat, Flags, PiTimeS)
Return the same piErr=-15010
sString (Length=1, (0)=0)
Can you tell me what's the proper coding for the above?
Did you initialize bSize to at least 6? You have to pass a value to tell pisn_getsnapshotx how big the buffer pointed to by sString is... it has no idea. In your example, since you redimensioned it to 256, set bSize to 256 before calling pisn_getsnapshotx().
Sorry, I was working on my other program and didn't try it immediately.
Yes, I set bZize=256 and try it again, but this time it returned piErr=0, bSize=5 and sString=257 (but all values are (0)). Err.Description="Method's type signature is not Interrop compatible.". I doubt the PI library I use could be too old.
Forget about my problem on PI API pisn_getsnapshotx (), I will use PI OLEDB Provider to get data from PI. Thanks.
Did you find everything ok with OLEDB or did you want to revisit using your custom code?
Happy to help
No, I gave up PI API method and use PI OLEDB. So far PI OLEDB is working good for me. Thanks.
can i ask u some question,where do you find the PI API documnets for VB6??? I couldn't find any file about VB6 of PI API function