Issues with scope on a text box after .net conversion from vb6

K

kinarism

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?
 
G

GhostInAK

Hello (e-mail address removed),

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
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?
 
K

kinarism

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top