简体   繁体   English

将VB 6代码转换为VB.NET

[英]Converting VB 6 code to VB.NET

I am upgrading code from VB 6 to VB.NET, and the following code gives me an error: 我正在将代码从VB 6升级到VB.NET,以下代码给我一个错误:

(VB6.PixelsToTwipsX(mvarPicture.ClientRectangle.Width) - (BDR + X), 
VB6.PixelsToTwipsY(mvarPicture.ClientRectangle.Height) - (BDR + X)),
mvarBorderColor,
B

The error is: 错误是:

Error 6 End of statement expected. 错误6预期语句结尾。

Can anyone help me with that? 有人可以帮我吗?


This is the full code: 这是完整的代码:

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

Short answer, you're missing opening and closing parentheses on those lines. 简短的答案,您在这些行上缺少左括号和右括号。

Long answer, PictureBox.Line() is not supported in VB.NET. 长答案是,VB.NET不支持PictureBox.Line() Check out http://msdn.microsoft.com/en-us/library/9dtfzwyx(v=vs.90).aspx and http://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawline(v=vs.90).aspx for how to do it in .NET. 查看http://msdn.microsoft.com/en-us/library/9dtfzwyx(v=vs.90).aspxhttp://msdn.microsoft.com/en-us/library/system.drawing.graphics .drawline(v = vs.90).aspx ,了解如何在.NET中进行操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM