|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Issues with scope on a text box after .net conversion from vb6and didnt know the possibility of "cross-posting" was possible. Anyway, my post in the "upgrade" group hasnt gotten any response (probably due to noone reading it there) so I figured I would move this here for beter coverage. I've got a vb6 app that references a COM DLL. It is a single form app with and input textbox, a single button and a output textbox. When the user types into the input box and clicks the button, the app invokes a method from the DLL. an event fires when the DLL returns the results from the request and displays it in the text box. here is the calls being used in the DLL: void Request (BSTR bsWhat, long lHowmany) bsWhat - [in] What you want to retrieve data for lHowMany - [in] The maximum number of data points to be retrieved and then: STDMETHOD OnDataCompleted (INT iHowmany, VARIANT Time, VARIANT Data) iHowmany - [out] The number of data points returned. Time - [out] OLESafeArray containing timestamps for each data point Data - [out] OLESafeArray containing the datapoints so, without pasting all of the code, here are the relevent parts: first vb6 Dim WithEvents lookup As LookupInterface ' COM object Private Sub Form_Load Set lookup = new LookupInterface End Sub Private Sub Button_Click() lookup.Request(input.text, 10) End Sub Private Sub lookup_OnDataCompleted(ByVal lHowmany As Long, ByVal aTime As Variant, ByVal aData As Variant) Dim i as long For i = 0 to lHowmany Output.Text = Output.text & aTime(i) & aData(i) & vbcrlf Next i end sub this code works perfectly in vb6... when i loaded the project in vb.net 2005 and ran the conversion wizard, the code is now: Friend Class LookupClass Dim WithEvents lookup As LookupInterface ' COM object Private Sub Form_Load lookup = new LookupInterface End Sub Private Sub Button_Click() lookup.Request(input.text, CInt(10)) End Sub Private Sub lookup_OnDataCompleted(ByVal lHowmany As Integer, ByVal aTime As Object, ByVal Data As Object) Handles lookup.OnDataCompleted Dim i as integer For i = 0 to lHowmany 'UPGRADE_WARNING: Couldn't resolve default property of object Data(i). 'UPGRADE_WARNING: Couldn't resolve default property of object aTime(i) Output.Text = Output.text & aTime(i) & aData(i) & vbcrlf Next i End Sub End Class Now...this works fine as well in 2k5 with the exception that the data never gets displayed in the output box. upon debugging, when the data is returned in the arrays, everything looks fine, but the Output.Text shows that it appears to be out of scope giving an 'error: cannot obtain value' any ideas as to why this might be happening? Hello kinar***@gmail.com,
Why in the Hell would you run a conversion wizard on such a small chunk of code. Be a damn programmer, ya lazy-ass. -Boo Show quoteHide quote > Sorry for posting on multiple groups with this, I am new to the groups > and didnt know the possibility of "cross-posting" was possible. > Anyway, my post in the "upgrade" group hasnt gotten any response > (probably due to noone reading it there) so I figured I would move > this > here for beter coverage. > I've got a vb6 app that references a COM DLL. It is a single form app > with and input textbox, a single button and a output textbox. > > When the user types into the input box and clicks the button, the app > invokes a method from the DLL. > > an event fires when the DLL returns the results from the request and > displays it in the text box. > > here is the calls being used in the DLL: > > void Request (BSTR bsWhat, long lHowmany) > bsWhat - [in] What you want to retrieve data for > lHowMany - [in] The maximum number of data points to be retrieved > and then: > > STDMETHOD OnDataCompleted (INT iHowmany, VARIANT Time, VARIANT Data) > iHowmany - [out] The number of data points returned. > Time - [out] OLESafeArray containing timestamps for each data point > Data - [out] OLESafeArray containing the datapoints > so, without pasting all of the code, here are the relevent parts: > > first vb6 > > Dim WithEvents lookup As LookupInterface ' COM object > > Private Sub Form_Load > Set lookup = new LookupInterface > End Sub > Private Sub Button_Click() > lookup.Request(input.text, 10) > End Sub > Private Sub lookup_OnDataCompleted(ByVal lHowmany As Long, ByVal aTime > As Variant, ByVal aData As Variant) > Dim i as long > For i = 0 to lHowmany > Output.Text = Output.text & aTime(i) & aData(i) & vbcrlf > Next i > end sub > this code works perfectly in vb6... when i loaded the project in > vb.net 2005 and ran the conversion wizard, the code is now: > > Friend Class LookupClass > Dim WithEvents lookup As LookupInterface ' COM object > Private Sub Form_Load > lookup = new LookupInterface > End Sub > Private Sub Button_Click() > lookup.Request(input.text, CInt(10)) > End Sub > Private Sub lookup_OnDataCompleted(ByVal lHowmany As Integer, ByVal > aTime As Object, ByVal Data As Object) Handles lookup.OnDataCompleted > Dim i as integer > For i = 0 to lHowmany > 'UPGRADE_WARNING: Couldn't resolve default property of object > Data(i). > 'UPGRADE_WARNING: Couldn't resolve default property of object > aTime(i) > Output.Text = Output.text & aTime(i) & aData(i) & vbcrlf > Next i > End Sub > End Class > Now...this works fine as well in 2k5 with the exception that the data > never gets displayed in the output box. > > upon debugging, when the data is returned in the arrays, everything > looks fine, but the Output.Text shows that it appears to be out of > scope giving an 'error: cannot obtain value' > > any ideas as to why this might be happening? > Thanks for the insightful, slightly preddictable, response.
This project was part of a much larger solution (about 30 apps in all). It is one of about 5 that didnt convert correctly all of which have the same problem.
Passing data from one VB.Net application to another
Detect mouse movement from minimized application Build a Program Now! VB2005 Help with System.Timers.Timer in a module how to do this? Is this the most efficient/fastest code to use? (beginner sql question) "File is being used by another process" - error Form & Designer File Becoming Separated date/time in different formats text file problem |
|||||||||||||||||||||||