Surendra Sharma

Surendra Sharma

Search This Blog

Tuesday, July 23, 2013

’Value of type 'String' cannot be converted to 'System.Windows.Forms.ListViewItem.ListViewSubItem'.

During migration from VB to VB.NET if you are getting error as "’Value of type 'String' cannot be converted to 'System.Windows.Forms.ListViewItem.ListViewSubItem'." with following type of code


'UPGRADE_WARNING: Lower bound of collection mylistview.ListItems has changed from 1 to 0
'UPGRADE_WARNING: Lower bound of collection mylistview.ListItems().ListSubItems has changed from 1 to 0. 'UPGRADE_WARNING: Couldn't resolve default property of object mylistview.ListItems().ListSubItems().

mylistview.Items.Item(currentIndex).SubItems.Item(1) = "Test"

Solution: -

Use “Text” property to assign value as below


mylistview.Items.Item(currentIndex).SubItems.Item(1).Text = "Test"

’Value of type 'Microsoft.VisualBasic.FileAttribute' cannot be converted to 'System.Windows.Forms.Cursor'.

During migration from VB to VB.NET if you are getting error as "’Value of type 'Microsoft.VisualBasic.FileAttribute' cannot be converted to 'System.Windows.Forms.Cursor'." with following type of code

'UPGRADE_ISSUE: Unable to determine which constant to upgrade vbNormal to. 'UPGRADE_ISSUE: Screen property Screen.MousePointer does not support custom mousepointers.
'UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior.
System.Windows.Forms.Cursor.Current = vbNormal

Solution: -
Use “Cursors.Default” as below


System.Windows.Forms.Cursor.Current = Cursors.Default

'NewIndex' is not a member of 'System.Windows.Forms.CheckedListBox'

During migration from VB to VB.NET if you are getting error as "'NewIndex' is not a member of 'System.Windows.Forms.CheckedListBox'" with following type of code


myCheckedListBox.Items.Add("MatchName")
'UPGRADE_ISSUE: ListBox property myCheckedListBox.NewIndex was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="F649E068-7137-45E5-AC20-4D80A3CC70AC"'
myCheckedListBox.SetSelected(myCheckedListBox.NewIndex, False)

Solution: -
Store number of newly added item of CheckedListBox in some variable and use that value in place of “NexIndex” as below

Dim currentItemNumber As Integer = myCheckedListBox.Items.Add("MatchName")

myCheckedListBox.SetSelected(currentItemNumber, False)

'SelLength' is not a member of 'System.Windows.Forms.Control'.

During migration from VB to VB.NET if you are getting error as "'SelLength' is not a member of 'System.Windows.Forms.Control'." with following type of code


'UPGRADE_WARNING: Couldn't resolve default property of object mytextbox.SelLength.
mytextbox.SelLength = 0
Solution: -
Use new property “SelectionLength” as below

mytextbox.SelectionLength = 0

'SelStart' is not a member of 'System.Windows.Forms.Control'.

During migration from VB to VB.NET if you are getting error as "'SelStart' is not a member of 'System.Windows.Forms.Control'." with following type of code


'UPGRADE_WARNING: Couldn't resolve default property of object frmForm.ActiveControl.SelStart.
mytextbox.SelStart = 0
Solution: -
Use new property “SelectionStart” as below
mytextbox.SelectionStart = 0

'NewIndex' is not a member of 'System.Windows.Forms.ListBox'

During migration from VB to VB.NET if you are getting error as "'NewIndex' is not a member of 'System.Windows.Forms.ListBox'" with following type of code


mylistbox.Items.Add("MatchName")
'UPGRADE_ISSUE: ListBox property mylistbox.NewIndex was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="F649E068-7137-45E5-AC20-4D80A3CC70AC"'
mylistbox.SetSelected(mylistbox.NewIndex, False)

Solution: -
Store newly added item in listbox’s number in some variable and use that value in place of “NexIndex” as below
Dim currentItemNumber As Integer = mylistbox.Items.Add("MatchName")

mylistbox.SetSelected(currentItemNumber, False)

'Me' cannot be the target of an assignment.

During migration from VB to VB.NET if you are getting error as "'Me' cannot be the target of an assignment." with following type of code

'UPGRADE_NOTE: Object frmDSNs may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
Me = Nothing

Solution: - Just find and replace
Me = Nothing
with
'Me = Nothing

in entire project