回 帖 发 新 帖 刷新版面

主题:改程序!!!!!!!!!!!!!

这是一个用VB做的游戏,哪位高手能把他改成一个VB。NET上能运行的程序,不胜感激!!!!


Option Explicit
Dim mbPlay As Boolean
Dim Direction As Integer
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If mbPlay = False Then Exit Sub
If KeyCode = vbKeyUp Then You.Top = You.Top - 10
If KeyCode = vbKeyDown Then You.Top = You.Top + 10
End Sub

Private Sub Form_Load()
Direction = 1
End Sub

Private Sub Form_Resize()
ln.X1 = ScaleWidth / 2
ln.X2 = ln.X1
ln.Y1 = 0
ln.Y2 = ScaleHeight
End Sub

Private Sub mnuAbout_Click()
MsgBox "This program is made by" + vbCrLf + "20272甲" + vbCrLf + "成城(20272133)", vbOKOnly, "About"
End Sub

Private Sub mnuGameExit_Click()
Unload Me
End Sub
Private Sub mnuGamePause_Click()
mbPlay = Not mbPlay
If mnuGamePause.Caption = "&Play" Then mnuGamePause.Caption = "&Pause" Else mnuGamePause.Caption = "&Play"
End Sub
Private Sub mnuGameStart_Click()
You.Visible = True
Op.Visible = True
Ball.Visible = True
mbPlay = True
mnuGamePause.Enabled = True
End Sub

Private Sub tmrBall_Timer()
If mbPlay = False Then Exit Sub
Dim Was As Boolean
If (Ball.Left + Ball.Width) >= Op.Left Then
    If Ball.Top >= Op.Top Then
        If Ball.Top <= (Op.Top + Op.Height) Then
            If Direction = 1 Then Direction = 0
        End If
    End If
End If
If Ball.Left < (You.Left + You.Width) Then
    If Ball.Top > You.Top Then
        If Ball.Top <= (You.Top + You.Height) Then
            If Direction = 0 Then Direction = 1
        End If
    End If
End If
If Ball.Left <= 0 Then GameOver
If Ball.Left >= Me.ScaleWidth Then GameOver
If Direction = 0 Then Ball.Left = Ball.Left - 10
If Direction = 1 Then Ball.Left = Ball.Left + 10
End Sub
Sub GameOver()
MsgBox "Game Over!", vbExclamation
mbPlay = False
Ball.Left = Me.ScaleWidth / 2
You.Top = Me.ScaleHeight / 2 - You.Height / 2
Op.Top = You.Top
End Sub

回复列表 (共6个回复)

沙发

Option Strict Off
Option Explicit On
Friend Class Form1
    Inherits System.Windows.Forms.Form
#Region "Windows 窗体设计器生成的代码"
    Public Sub New()
        MyBase.New()
        If m_vb6FormDefInstance Is Nothing Then
            If m_InitializingDefInstance Then
                m_vb6FormDefInstance = Me
            Else
                Try
                    '对于启动窗体,所创建的第一个实例为默认实例。
                    If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType Is Me.GetType Then
                        m_vb6FormDefInstance = Me
                    End If
                Catch
                End Try
            End If
        End If
        '此调用是 Windows 窗体设计器所必需的。
        InitializeComponent()
    End Sub
    '窗体重写处置,以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
        If Disposing Then
            If Not components Is Nothing Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(Disposing)
    End Sub
    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer
    Public ToolTip1 As System.Windows.Forms.ToolTip
    Public WithEvents Ln As System.Windows.Forms.Label
    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器来修改它。
    '不要使用代码编辑器修改它。
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
        Me.components = New System.ComponentModel.Container()
        Me.ToolTip1 = New System.Windows.Forms.ToolTip(components)
        Me.ToolTip1.Active = True
        Me.Ln = New System.Windows.Forms.Label
        Me.Text = "Form1"
        Me.ClientSize = New System.Drawing.Size(312, 213)
        Me.Location = New System.Drawing.Point(4, 23)
        Me.StartPosition = System.Windows.Forms.FormStartPosition.WindowsDefaultLocation
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.BackColor = System.Drawing.SystemColors.Control
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable
        Me.ControlBox = True
        Me.Enabled = True
        Me.KeyPreview = False
        Me.MaximizeBox = True
        Me.MinimizeBox = True
        Me.Cursor = System.Windows.Forms.Cursors.Default
        Me.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.ShowInTaskbar = True
        Me.HelpButton = False
        Me.WindowState = System.Windows.Forms.FormWindowState.Normal
        Me.Name = "Form1"
        Me.Ln.Text = "Label1"
        Me.Ln.Size = New System.Drawing.Size(65, 41)
        Me.Ln.Location = New System.Drawing.Point(64, 40)
        Me.Ln.TabIndex = 0
        Me.Ln.TextAlign = System.Drawing.ContentAlignment.TopLeft
        Me.Ln.BackColor = System.Drawing.SystemColors.Control
        Me.Ln.Enabled = True
        Me.Ln.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Ln.Cursor = System.Windows.Forms.Cursors.Default
        Me.Ln.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Ln.UseMnemonic = True
        Me.Ln.Visible = True
        Me.Ln.AutoSize = False
        Me.Ln.BorderStyle = System.Windows.Forms.BorderStyle.None
        Me.Ln.Name = "Ln"
        Me.Controls.Add(Ln)
    End Sub
#End Region
#Region "升级支持"
    Private Shared m_vb6FormDefInstance As Form1
    Private Shared m_InitializingDefInstance As Boolean
    Public Shared Property DefInstance() As Form1
        Get
            If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then
                m_InitializingDefInstance = True
                m_vb6FormDefInstance = New Form1()
                m_InitializingDefInstance = False
            End If
            DefInstance = m_vb6FormDefInstance
        End Get
        Set
            m_vb6FormDefInstance = Value
        End Set
    End Property
#End Region
    Dim mbPlay As Boolean
    Dim Direction As Short
    Private Sub Form1_KeyDown(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        Dim KeyCode As Short = eventArgs.KeyCode
        Dim Shift As Short = eventArgs.KeyData \ &H10000
        Dim You As Object
        If mbPlay = False Then Exit Sub

        If KeyCode = System.Windows.Forms.Keys.Up Then You.Top = You.Top - 10

        If KeyCode = System.Windows.Forms.Keys.Down Then You.Top = You.Top + 10
    End Sub
    
    Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
        Direction = 1
    End Sub
    

    Private Sub Form1_Resize(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Resize

        Ln.X1 = VB6.PixelsToTwipsX(ClientRectangle.Width) / 2
        
        Ln.X2 = Ln.X1
        tm?keyword="vbup1037"”
        Ln.Y1 = 0

        Ln.Y2 = VB6.PixelsToTwipsY(ClientRectangle.Height)
    End Sub
    
    Private Sub mnuAbout_Click()
        MsgBox("This program is made by" & vbCrLf & "20272甲" & vbCrLf & "成城(20272133)", MsgBoxStyle.OKOnly, "About")
    End Sub
    
    Private Sub mnuGameExit_Click()
        Me.Close()
    End Sub
    Private Sub mnuGamePause_Click()
        Dim mnuGamePause As Object
        mbPlay = Not mbPlay

        If mnuGamePause.Caption = "&Play" Then
            mnuGamePause.Caption = "&Pause"
        Else
        End If
    End Sub
    Private Sub mnuGameStart_Click()
        Dim mnuGamePause As Object
        Dim Ball As Object
        Dim Op As Object
        Dim You As Object
        You.Visible = True
        Op.Visible = True
        Ball.Visible = True
        mbPlay = True
        mnuGamePause.Enabled = True
    End Sub
    
    Private Sub tmrBall_Timer()
        Dim You As Object
        Dim Op As Object
        Dim Ball As Object
        If mbPlay = False Then Exit Sub
        Dim Was As Boolean
        If (Ball.Left + Ball.Width) >= Op.Left Then
            If Ball.Top >= Op.Top Then
                If Ball.Top <= (Op.Top + Op.Height) Then
                    If Direction = 1 Then Direction = 0
                End If
            End If
        End If
        If Ball.Left < (You.Left + You.Width) Then

            If Ball.Top > You.Top Then
                If Ball.Top <= (You.Top + You.Height) Then
                    If Direction = 0 Then Direction = 1
                End If
            End If
        End If
        If Ball.Left <= 0 Then GameOver()
        If Ball.Left >= VB6.PixelsToTwipsX(Me.ClientRectangle.Width) Then GameOver()
        If Direction = 0 Then Ball.Left = Ball.Left - 10
        If Direction = 1 Then Ball.Left = Ball.Left + 10
    End Sub
    Sub GameOver()
        Dim Op As Object
        Dim You As Object
        Dim Ball As Object
        MsgBox("Game Over!", MsgBoxStyle.Exclamation)
        mbPlay = False
        Ball.Left = VB6.PixelsToTwipsX(Me.ClientRectangle.Width) / 2
        You.Top = VB6.PixelsToTwipsY(Me.ClientRectangle.Height) / 2 - You.Height / 2
        Op.Top = You.Top
    End Sub
End Class

板凳

你只要在语法上改一下就可以了,

3 楼

是这样就可以运行了马
还需要改哪里?

4 楼

VB.net不是内置有6.0代码转net的工具的嘛,打开6.0工程,然后照着它的提示就可以了

5 楼

说具体一点,在哪里转换呢

6 楼

下载转换软件了

我来回复

您尚未登录,请登录后再回复。点此登录或注册