For i = 0 To 2
If Niz1(i) > Niz2(i) Then
a = Niz1(i)
b = Niz2(i)
Call ZamjenaNiza(a, b)
Niz1(i) = Prvi
Niz2(i) = Drugi
End If
Next i
For j = 0 To 3
Me.DataGridView(j + 1, 1) = Niz1(j)
Me.DataGridView(j + 1, 2) = Niz2(j)
Next j
End Sub
任何人都可以帮我解决这个问题吗?无法找到解决方案,甚至在Visual Basic帮助页面上也找不到!它显示了这2个代码行的错误:
Me.DataGridView(j + 1, 1) = Niz1(j)
Me.DataGridView(j + 1, 2) = Niz2(j)
它说:类型的价值' Single'无法转换为' System.Windows.Forms.DataGridViewCell'
答案 0 :(得分:2)
不应尝试将Single
值分配给DataGridViewCell对象,而应将其分配给对象的.Value
属性。
Me.DataGridView(j + 1, 1).Value = Niz1(j)