我正在将代码从VB 6升级到VB.NET,以下代码给出了一个错误:
(VB6.PixelsToTwipsX(mvarPicture.ClientRectangle.Width) - (BDR + X),
VB6.PixelsToTwipsY(mvarPicture.ClientRectangle.Height) - (BDR + X)),
mvarBorderColor,
B
错误是:
错误6预期结束语句。
任何人都可以帮助我吗?
这是完整的代码:
Public Sub Draw()
Dim BDR, X As Short
Dim NewX, NewY As Double
Dim OldX, OldY As Double
Dim GridHeight, GridWidth As Double
Dim mvarPictureBox As System.Windows.Forms.PictureBox
On Error GoTo NoPicBox ' In case the PicBox isn't set yet
'UPGRADE_ISSUE: PictureBox property mvarPictureBox.AutoRedraw was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
If mvarPicture.AutoRedraw = False Then mvarPicture.AutoRedraw = True
'UPGRADE_ISSUE: PictureBox method mvarPictureBox.Cls was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
mvarPicture.Cls()
BDR = mvarPictureBox.BorderStyle
'UPGRADE_ISSUE: PictureBox property mvarPictureBox.ScaleMode was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
If mvarPicture.ScaleMode <> 3 Then mvarPicture.ScaleMode = 3
If System.Drawing.ColorTranslator.ToOle(mvarPictureBox.BackColor) <> System.Drawing.ColorTranslator.ToOle(mvarPicBackground) Then mvarPictureBox.BackColor = mvarPicBackground
If mvarBorderSize > 0 Then
For X = 0 To mvarBorderSize
'UPGRADE_ISSUE: PictureBox method mvarPictureBox.Line was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
mvarPicture.Line (X, X) - (VB6.PixelsToTwipsX(mvarPicture.ClientRectangle.Width) - (BDR + X), VB6.PixelsToTwipsY(mvarPicture.ClientRectangle.Height) - (BDR + X)), mvarBorderColor, B
Next X
End If
' Display Grid On Screen
If mvarGridVisible = True Then
For X = 1 To 20
'UPGRADE_ISSUE: PictureBox method mvarPictureBox.Line was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
mvarPicture.Line (mvarBorderSize, mvarBorderSize) - ((((VB6.PixelsToTwipsX(mvarPictureBox.ClientRectangle.Width) - (mvarBorderSize * 2)) / 20) * X), (VB6.PixelsToTwipsY(mvarPictureBox.ClientRectangle.Height) - (mvarBorderSize * 2))), mvarGridColor, B
Next X
For X = 1 To 10
'UPGRADE_ISSUE: PictureBox method mvarPictureBox.Line was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
mvarPicture.Line (mvarBorderSize, mvarBorderSize) - ((VB6.PixelsToTwipsX(mvarPictureBox.ClientRectangle.Width) - (mvarBorderSize * 2)), (((VB6.PixelsToTwipsY(mvarPictureBox.ClientRectangle.Height) - (mvarBorderSize * 2)) / 10) * X)), mvarGridColor, B
Next X
End If
If mvarDataCollection.Count() > 0 Then
GridHeight = ((VB6.PixelsToTwipsY(mvarPictureBox.ClientRectangle.Height) - (mvarBorderSize * 2)) / 100) + 0 ' 0-100%
GridWidth = ((VB6.PixelsToTwipsX(mvarPictureBox.ClientRectangle.Width) - (mvarBorderSize * 2)) / 100) + 0 ' 1-100 Items
Do
If mvarDataCollection.Count() > 100 Then mvarDataCollection.Remove(1)
Loop While mvarDataCollection.Count() > 100
OldX = mvarBorderSize + 2
'UPGRADE_WARNING: Couldn't resolve default property of object mvarDataCollection(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
OldY = ((VB6.PixelsToTwipsY(mvarPictureBox.ClientRectangle.Height) - (mvarBorderSize * 2)) - (mvarDataCollection.Item(1) * GridHeight))
For X = 1 To 100
NewX = (VB6.PixelsToTwipsX(mvarPictureBox.ClientRectangle.Width) - (mvarBorderSize * 2)) - ((100 - (X - 1)) * GridWidth)
'UPGRADE_WARNING: Couldn't resolve default property of object mvarDataCollection(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
NewY = ((VB6.PixelsToTwipsY(mvarPictureBox.ClientRectangle.Height) - (mvarBorderSize * 2)) - (mvarDataCollection.Item(X) * GridHeight))
NewX = NewX + 2
If NewX < mvarBorderSize Then NewX = mvarBorderSize
If NewY < mvarBorderSize Then NewY = mvarBorderSize
'UPGRADE_ISSUE: PictureBox method mvarPictureBox.Line was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
mvarPicture.Line (OldX, OldY) - (NewX, NewY), mvarPicForeground
OldX = NewX : OldY = NewY
If OldX < mvarBorderSize Then OldX = mvarBorderSize
If OldY < mvarBorderSize Then OldY = mvarBorderSize
Next X
End If
NoPicBox:
End Sub
答案 0 :(得分:2)
简短回答,你错过了那些行上的开括号和右括号。
长期回答,VB.NET不支持PictureBox.Line()
。查看http://msdn.microsoft.com/en-us/library/9dtfzwyx(v=vs.90).aspx和http://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawline(v=vs.90).aspx了解如何在.NET中执行此操作。